anchor.diff:                              [],
                               Interval,
                               MaxNum),
  -    ?equals_w_note(lists:sort(ScrubbedData), lists:sort(AllFold), "test_foldl1"),
  -    ?equals_w_note(lists:sort(ExpInInterval), lists:sort(IntervalFold), "test_foldl2"),
  -    ?equals_w_note(lists:sort(ExpInIntervalCounted),
  -                   lists:sort(IntervalCountFold), "test_foldl3"),
  +    %% we expect all data from fold to be in reversed order because of list
  +    %% accumulation. we need to reverse ScrubbedData, ExpInInterval and
  +    %% ExpInIntervalCounted.
  +    ?equals_w_note(lists:reverse(ScrubbedData), AllFold, "test_foldl1"),
  +    ?equals_w_note(lists:reverse(ExpInInterval), IntervalFold, "test_foldl2"),
  +    ?equals_w_note(lists:reverse(ExpInIntervalCounted), IntervalCountFold, "test_foldl3"),
       ?TEST_DB:close(DB1),
       true.
   
  
positive.code:         write_scrubbed_to_db(?TEST_DB:new(randoms:getRandomString()), Data),
      ExpInInterval = [El || El <- ScrubbedData,
                             is_in(Interval, element(1, El))],
      ExpInIntervalCounted = lists:sublist(lists:keysort(1, ExpInInterval), MaxNum),
      AllFold = ?TEST_DB:foldl(DB1, fun(E, AccIn) -> [E | AccIn] end, []),
      IntervalFold = ?TEST_DB:foldl(DB1,
                                   fun(E, AccIn) -> [E | AccIn] end,
  
negative.code:         write_scrubbed_to_db(?TEST_DB:new(randoms:getRandomString()), Data),
      ExpInInterval = [El || El <- ScrubbedData,
                             is_in(Interval, element(1, El))],
      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,
  