anchor.diff:  %% @doc Checks that a key is present exactly once in the list of deleted
   %%      keys returned by ?TEST_DB:get_changes/1 if no lock is set on a
   %%      previously existing entry.
  --spec check_key_in_deleted(
  +-spec check_key_in_deleted_no_locks(
           DB::?TEST_DB:db(), ChangesInterval::intervals:interval(), Key::?RT:key(),
           {OldExists::boolean(), OldEntry::db_entry:entry()}, Note::string()) -> true.
  -check_key_in_deleted(DB, ChangesInterval, Key, {OldExists, OldEntry}, Note) ->
  +check_key_in_deleted_no_locks(DB, ChangesInterval, Key, {OldExists, OldEntry}, Note) ->
       case intervals:in(Key, ChangesInterval) andalso OldExists andalso
                (db_entry:get_writelock(OldEntry) =:= false andalso
                     db_entry:get_readlock(OldEntry) =:= 0) of
           true ->
               {_ChangedEntries, DeletedKeys} = ?TEST_DB:get_changes(DB),
  -            case length([K || K <- DeletedKeys, K =:= Key]) of
  -                1 -> true;
  -                _ -> ?ct_fail("element(2, ?TEST_DB:get_changes(DB)) evaluated "
  -                              "to \"~w\" and did not contain 1x key ~w~n(~s)~n",
  -                              [DeletedKeys, Key, lists:flatten(Note)])
  -            end;
  +            check_key_in_deleted_internal(DeletedKeys, ChangesInterval, Key, OldExists, Note);
           _    -> true
       end.
   
  
positive.code:     
      {DB4, _Status} = ?TEST_DB:delete(DB3, Key),
      check_changes(DB4, ChangesInterval, "delete_1"),
      check_key_in_deleted(DB4, ChangesInterval, Key, Old, "delete_2"),
      
      DB5 = check_stop_record_changes(DB4, ChangesInterval, "delete_3"),
  
  
negative.code:         Keys::[{?RT:key(), OldExists::boolean()}], Note::string()) -> true.
  check_keys_in_deleted(DB, ChangesInterval, Keys, Note) ->
      {_ChangedEntries, DeletedKeys} = ?TEST_DB:get_changes(DB),
      [check_key_in_deleted_internal(DeletedKeys, ChangesInterval, Key, OldExists, Note)
      || {Key, OldExists} <- Keys],
      true.
  
  -spec check_key_in_deleted_internal(
          DeletedKeys::intervals:interval(), ChangesInterval::intervals:interval(),
          Key::?RT:key(), OldExists::boolean(), Note::string()) -> true.
  check_key_in_deleted_internal(DeletedKeys, ChangesInterval, Key, OldExists, Note) ->
      case intervals:in(Key, ChangesInterval) andalso OldExists of
          true ->
              case length([K || K <- DeletedKeys, K =:= Key]) of
                  1 -> ok;
                  _ -> ?ct_fail("element(2, ?TEST_DB:get_changes(DB)) evaluated "
                                "to \"~w\" and did not contain 1x key ~w~n(~s)~n",
                                [DeletedKeys, Key, lists:flatten(Note)])
              end;
          _    -> true
      end.
  
  %% @doc Checks that an entry is present exactly once in the list of changed
  %%      entries returned by ?TEST_DB:get_changes/1.
  -spec check_entry_in_changed_entries(
          DB::?TEST_DB:db(), ChangesInterval::intervals:interval(), Entry::db_entry:entry(),
          {OldExists::boolean(), OldEntry::db_entry:entry()}, Note::string()) -> ok.
  check_entry_in_changed_entries(DB, ChangesInterval, NewEntry, {_OldExists, OldEntry}, Note) ->
      {ChangedEntries, _DeletedKeys} = ?TEST_DB:get_changes(DB),
      check_entry_in_changed_entries_internal(ChangedEntries, ChangesInterval, NewEntry, OldEntry, Note).
  
  -spec check_entry_in_changed_entries_internal(
          ChangedEntries::?TEST_DB:db_as_list(), ChangesInterval::intervals:interval(),
          NewEntry::db_entry:entry(), OldEntry::db_entry:entry(), Note::string()) -> ok.
  check_entry_in_changed_entries_internal(ChangedEntries, ChangesInterval, NewEntry, OldEntry, Note) ->
      case intervals:in(db_entry:get_key(NewEntry), ChangesInterval) andalso
               OldEntry =/= NewEntry of
          true ->
              case length([E || E <- ChangedEntries, E =:= NewEntry]) of
                  1 -> ok;
                  _ -> ?ct_fail("~s evaluated to \"~w\" and did not contain 1x entry ~w~n(~s)~n",
  