anchor.diff:  -spec test_rdht_tx_read_commit_with_snap_1(any()) -> ok.
   test_rdht_tx_read_commit_with_snap_1(_) ->
       Db = ?TEST_DB:init_snapshot(?TEST_DB:new()),
  -    Entry = db_entry:new("key","val",1),
  -    TmpDb = ?TEST_DB:set_entry(Db,db_entry:inc_readlock(Entry)),
  -    NewDb = ?TEST_DB:set_snapshot_entry(TmpDb,db_entry:inc_readlock(Entry)),
  -    TLogEntry = tx_tlog:new_entry(rdht_tx_read,"key",1,value,1,?value,"val"),
  -    CommitDb = rdht_tx_read:commit(NewDb,TLogEntry,?prepared,1,2),
  -    SnapEntry = ?TEST_DB:get_snapshot_entry(CommitDb,"key"),
  -    ?equals({true,{"key","val",false,0,1}},SnapEntry), % no readlocks in snap db
  -    LiveEntry = ?TEST_DB:get_entry2(CommitDb,"key"),
  -    ?equals({true,{"key","val",false,0,1}},LiveEntry), % no readlocks in live db
  +    Entry = db_entry:new("key", "val", 1),
  +    TmpDb = ?TEST_DB:set_entry(Db, db_entry:inc_readlock(Entry)),
  +    NewDb = ?TEST_DB:set_snapshot_entry(TmpDb, db_entry:inc_readlock(Entry)),
  +    TLogEntry = tx_tlog:new_entry(rdht_tx_read, "key", 1, value, 1, ?value, "val"),
  +    CommitDb = rdht_tx_read:commit(NewDb, TLogEntry, ?prepared, 1, 2),
  +    SnapEntry = ?TEST_DB:get_snapshot_entry(CommitDb, "key"),
  +    ?equals({true, {"key", "val", false, 0, 1}}, SnapEntry), % no readlocks in snap db
  +    LiveEntry = ?TEST_DB:get_entry2(CommitDb, "key"),
  +    ?equals({true, {"key", "val", false, 0, 1}}, LiveEntry), % no readlocks in live db
       ok.
   
   % for "old" transactions (as in TM snapnr 1 is lesser than local snapnr 2) , changes
  
positive.code: -spec test_lock_counting_on_live_db(any()) -> ok.
  test_lock_counting_on_live_db(_) ->
      Db = ?TEST_DB:new(),
      Entry = db_entry:new("foo","bar",0),
      WriteLockEntry = db_entry:set_writelock(Entry,1),
      NewDB = {_,_,{_,LiveLC,_SnapLC}} = ?TEST_DB:set_entry(Db,WriteLockEntry),
      ?equals(LiveLC,1),
      {_,_,{_,NewLiveLC,_}} = ?TEST_DB:set_entry(NewDB,Entry),
      ?equals(NewLiveLC,0),
      ok.
      
  
  
negative.code: -spec test_rdht_tx_write_validate_db_copy(any()) -> ok.
  test_rdht_tx_write_validate_db_copy(_) ->
      Db = ?TEST_DB:init_snapshot(?TEST_DB:new()),
      Db = ?TEST_DB:set_entry(Db, db_entry:new("key", "val", 1)),
      TLogEntry = tx_tlog:new_entry(rdht_tx_write, "key", 1, value, 1, ?value, "new_val"),
      {NewDb, _Vote} = rdht_tx_write:validate(Db, 1, TLogEntry),
      SnapEntry = ?TEST_DB:get_snapshot_entry(NewDb, "key"),
      ?equals({true, {"key", "val", false, 0, 1}}, SnapEntry), % no lock in snap db
      LiveEntry = ?TEST_DB:get_entry2(NewDb, "key"),
      ?equals({true, {"key", "val", 1, 0, 1}}, LiveEntry), % lock in live db
      ok.
  
  % for "old" transactions (as in TM snapnr 1 is lesser than local snapnr 2), changes should be applied to both dbs.
  -spec test_rdht_tx_write_commit_with_snap(any()) -> ok.
  test_rdht_tx_write_commit_with_snap(_) ->
      Db = ?TEST_DB:init_snapshot(?TEST_DB:new()),
      Entry = db_entry:new("key", "val", 1),
      TmpDb = ?TEST_DB:set_entry(Db, db_entry:set_writelock(Entry, 1)),
      NewDb = ?TEST_DB:set_snapshot_entry(TmpDb, db_entry:set_writelock(Entry, 1)),
      TLogEntry = tx_tlog:new_entry(rdht_tx_write, "key", 1, value, 1, ?value, "new_val"),
      CommitDb = rdht_tx_write:commit(NewDb, TLogEntry, ?prepared, 1, 2),
      SnapEntry = ?TEST_DB:get_snapshot_entry(CommitDb, "key"),
      ?equals({true, {"key", "new_val", false, 0, 2}}, SnapEntry), % no lock in snap db
      LiveEntry = ?TEST_DB:get_entry2(CommitDb, "key"),
      ?equals({true, {"key", "new_val", false, 0, 2}}, LiveEntry), % no lock in live db
      ok.
  
  % "new" transaction -> changes only on live db, snapshot db remains untouched
  -spec test_rdht_tx_write_commit_without_snap(any()) -> ok.
  test_rdht_tx_write_commit_without_snap(_) ->
      Db = ?TEST_DB:init_snapshot(?TEST_DB:new()),
      Entry = db_entry:new("key", "val", 1),
      TmpDb = ?TEST_DB:set_entry(Db, db_entry:set_writelock(Entry, 1)),
      NewDb = ?TEST_DB:set_snapshot_entry(TmpDb, db_entry:set_writelock(Entry, 1)),
      TLogEntry = tx_tlog:new_entry(rdht_tx_write, "key", 1, value, 2, ?value, "new_val"),
      CommitDb = rdht_tx_write:commit(NewDb, TLogEntry, ?prepared, 2, 2),
      SnapEntry = ?TEST_DB:get_snapshot_entry(CommitDb, "key"),
      ?equals({true, {"key", "val", 1, 0, 1}}, SnapEntry), % lock in snap db
      LiveEntry = ?TEST_DB:get_entry2(CommitDb, "key"),
      ?equals({true, {"key", "new_val", false, 0, 2}}, LiveEntry), % no lock in live db
      ok.
  
  % for "old" transactions (as in TM snapnr 1 is lesser than local snapnr 2), changes should be applied to both dbs.
  -spec test_rdht_tx_write_abort_with_snap(any()) -> ok.
  test_rdht_tx_write_abort_with_snap(_) ->
      Db = ?TEST_DB:init_snapshot(?TEST_DB:new()),
      Entry = db_entry:new("key", "val", 1),
      TmpDb = ?TEST_DB:set_entry(Db, db_entry:set_writelock(Entry, 1)),
      NewDb = ?TEST_DB:set_snapshot_entry(TmpDb, db_entry:set_writelock(Entry, 1)),
      ?equals({true, {"key", "val", 1, 0, 1}}, ?TEST_DB:get_entry2(Db, "key")),
      ?equals({true, {"key", "val", 1, 0, 1}}, ?TEST_DB:get_snapshot_entry(Db, "key")),
      TLogEntry = tx_tlog:new_entry(rdht_tx_write, "key", 1, value, 1, ?value, "new_val"),
      CommitDb = rdht_tx_write:abort(NewDb, TLogEntry, ?prepared, 1, 2),
      SnapEntry = ?TEST_DB:get_snapshot_entry(CommitDb, "key"),
      ?equals({true, {"key", "val", false, 0, 1}}, SnapEntry), % no lock in snap db
      LiveEntry = ?TEST_DB:get_entry2(CommitDb, "key"),
      ?equals({true, {"key", "val", false, 0, 1}}, LiveEntry), % no lock in live db
      ok.
  
  % "new" transaction -> changes only on live db, snapshot db remains untouched
  -spec test_rdht_tx_write_abort_without_snap(any()) -> ok.
  test_rdht_tx_write_abort_without_snap(_) ->
      Db = ?TEST_DB:init_snapshot(?TEST_DB:new()),
      Entry = db_entry:new("key", "val", 1),
      TmpDb = ?TEST_DB:set_entry(Db, db_entry:set_writelock(Entry, 1)),
      NewDb = ?TEST_DB:set_snapshot_entry(TmpDb, db_entry:set_writelock(Entry, 1)),
      TLogEntry = tx_tlog:new_entry(rdht_tx_write, "key", 1, value, 2, ?value, "new_val"),
      CommitDb = rdht_tx_write:abort(NewDb, TLogEntry, ?prepared, 1, 2),
      SnapEntry = ?TEST_DB:get_snapshot_entry(CommitDb, "key"),
      ?equals({true, {"key", "val", 1, 0, 1}}, SnapEntry), % lock in snap db
      LiveEntry = ?TEST_DB:get_entry2(CommitDb, "key"),
      ?equals({true, {"key", "val", false, 0, 1}}, LiveEntry), % no lock in live db
      ok.
  
  %%%%% lock counting tests
  