anchor.diff:                  type=Type,
                   log_id=LogId,
                   payload=Payload,
  -                opid= OpId,
  +                opid=OpId,
                   readresult=[],
  -                node_ops =[]},
  +                node_ops=[]},
       {ok, prepare, SD, 0}.
   
   %% @doc Prepare the write by calculating the _preference list_.
  
positive.code: %% @doc Find operations that are in List2 but not in List1
  -spec find_diff_ops(list(),list()) -> list().
  find_diff_ops(List1, List2) ->
      lists:filter(fun(X)-> lists:member(X, List1) == false end , List2).
  
  %% @doc Make a union of operations in L1 and L2
  %% TODO: Possible to simplify?
  %% FIXME: Add missing tests! And make sure that the tests also deal with corner cases, e.g. empty lists.
  -spec union_ops([{_,operation()}],[{_,operation()}],[{_,operation()}]) -> [{_,operation()}].
  union_ops(L1, L2, []) ->
      lists:append(L1, L2);
  union_ops(L1, L2, [Op|T]) ->
      {_, #operation{op_number= OpId}} = Op,
      L3 = remove_dup(L1, OpId,[]),
      L4 = lists:append(L2, [Op]),
      union_ops(L3, L4, T).
  
negative.code: -export([start_link/5]).
  
  %% Callbacks
  -export([init/1,
           code_change/4,
           handle_event/3,
           handle_info/3,
           handle_sync_event/4,
           terminate/3]).
  
  %% States
  -export([prepare/2,
           execute/2,
           wait_append/2,
           wait_read/2,
           repair_rest/2]).
  
  %% The threshold of number of error messages for read/write. When error
  %% message reaches this limit, the operation can not succeed.
  -define(W_ERROR_THRESHOLD, ?N-?NUM_W+1).
  -define(R_ERROR_THRESHOLD, ?N-?NUM_R+1).
  
  -record(state, {from :: pid(),
                  type :: term(),
                  log_id :: logid(),
                  payload :: payload(),
                  readresult,
                  error_msg = [],
                  preflist :: preflist(),
  