anchor.diff:          write_scrubbed_to_db(?TEST_DB:new(randoms:getRandomString()), Data),
       ExpInInterval = [El || El <- ScrubbedData,
                              is_in(Interval, element(1, El))],
  -    ExpInIntervalCounted = lists:sublist(lists:reverse(lists:keysort(1, ExpInInterval)), MaxNum),
  +    ExpInIntervalCounted = case MaxNum >= length(ExpInInterval) of
  +                               true ->
  +                                   ExpInInterval;
  +                               _ ->
  +                                   lists:nthtail(length(ExpInInterval) - MaxNum, ExpInInterval)
  +                           end,
       AllFold = ?TEST_DB:foldr(DB1, fun(E, AccIn) -> [E | AccIn] end, []),
       IntervalFold = ?TEST_DB:foldr(DB1,
                                    fun(E, AccIn) -> [E | AccIn] end,
  
positive.code:                             MaxNum),
      %% ct:pal("ExpInInterval: ~p~nIntervalFold: ~p~nInterval: ~p~n", [ExpInInterval,
      %%                                                  IntervalFold, Interval]),
      ?equals_w_note(lists:sort(ScrubbedData), lists:sort(AllFold), "test_foldr1"),
      ?equals_w_note(lists:sort(ExpInInterval), lists:sort(IntervalFold), "test_foldr2"),
      ?equals_w_note(lists:sort(ExpInIntervalCounted),
                     lists:sort(IntervalCountFold), "test_foldr3"),
      ?TEST_DB:close(DB1),
      true.
  
  
negative.code:     %% Entries should be unique
      SortFun = fun(A, B) -> (element(1, A) < element(1, B)) orelse
                             (element(1, A) ?EQ element(1, B)) end,
      lists:usort(SortFun, Data).
  
  check_db(DB, ExpData, Note) ->
      InDb = ?TEST_DB:foldl(DB, fun(E, AIn) -> [E | AIn] end, []),
  