anchor.diff:  %%% Internal functions
   %%%===================================================================
   
  -%% Receive all messages with given prefix
  +%% Saves docs for given value, model and range of keys
  +save_docs(Worker, Value, Model, FirstKey, LastKey) ->
  +    lists:map(
  +        fun(Key) ->
  +            Doc = #document{key = Key, value = Value},
  +            ?assertEqual({ok, Key}, rpc:call(Worker, Model, save, [Doc])),
  +            {Key, Value, Model}
  +        end,
  +        lists:seq(FirstKey, LastKey)
  +    ).
  +
  +%% Receives all messages with given prefix
   receive_all(Prefix, Received) ->
       receive
  +        {Prefix, {_, stream_ended, _}} ->
  +            lists:usort(Received);
           {Prefix, Data} ->
               receive_all(Prefix, [Data | Received])
       after
  
positive.code:                 fun(Seq, Doc, Mod) ->
                      Pid ! {finite, {Seq, Doc, Mod}}
                  end,
                  FirstSeq,
                  LastSeq
              ]
          )
      ),
  
      lists:map(
          fun({Seq, #document{key = Key, value = Val}, Mod}) ->
              ?assertReceivedMatch({finite,
                  {Seq, #document{key = Key, value = Val}, Mod}}, ?TIMEOUT)
          end,
          Received
      ),
  
      ?assertEqual(ok, rpc:call(W, gen_changes, stop, [DriverPid])),
      ok.
  
negative.code:             lists:usort(Received)
      end.
  
  %% Cleans mailbox
  flush() ->
      receive
          _ ->
  