anchor.diff:          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,
  +    ExpInIntervalCounted =
  +        case MaxNum >= length(ExpInInterval) of
  +            true ->
  +                ExpInInterval;
  +            _ ->
  +                EndIndex = length(ExpInInterval) - MaxNum,
  +                Counted = lists:nthtail(EndIndex, ExpInInterval),
  +                %% The same reason as for prop_foldl, but instead of adding, drop
  +                %% all elements of the splitted sequence.
  +                case MaxNum == 0 of
  +                    true ->
  +                        Counted;
  +                    _ ->
  +                        lists:dropwhile(fun(E) ->
  +                                element(1, lists:nth(EndIndex, ExpInInterval)) ==
  +                                element(1, E)
  +                        end, Counted)
  +                end
  +        end,
  +
       AllFold = ?TEST_DB:foldr(DB1, fun(K, AccIn) -> [?TEST_DB:get(DB1, K) | AccIn] end, []),
       IntervalFold = ?TEST_DB:foldr(DB1,
                                    fun(K, AccIn) -> [?TEST_DB:get(DB1, K) | AccIn] end,
  
positive.code:     true.
  
  tester_foldr(_Config) ->
      tester:test(?MODULE, prop_foldr, 3, rw_suite_runs(10000), [{threads, 2}]).
  
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  
negative.code:     ExpInInterval = [El || El <- ScrubbedData,
                             is_in(Interval, element(1, El))],
      ExpInIntervalCounted = lists:sublist(ExpInInterval, MaxNum),
      %% We have certain combination of keys (e.g. {0} and {0.0}]) which are returned
      %% in an unspecified order by certain DBs (lets call that a sequenze). If MaxNum
      %% is set to a value which would split such a sequenz the test might fail because
      %% the DBs returns unexpected keys. In such case all remaining elements of the sequenze
      %% are added as well (which effectivly increases MaxNum).
      ExpInIntervalCountedTailed =
          case MaxNum >= length(ExpInInterval) orelse MaxNum == 0 of
              true ->
                  ExpInIntervalCounted;
              _ ->
                  Tail = lists:takewhile(fun(E) ->
                                              element(1, lists:last(ExpInIntervalCounted)) ==
                                              element(1, E)
                                         end, lists:nthtail(MaxNum, ExpInInterval)),
                  lists:append(ExpInIntervalCounted, Tail)
          end,
  
      AllFold = ?TEST_DB:foldl(DB1, fun(K, AccIn) -> [?TEST_DB:get(DB1, K) | AccIn] end, []),
      IntervalFold = ?TEST_DB:foldl(DB1,
                                   fun(K, AccIn) -> [?TEST_DB:get(DB1, K) | AccIn] end,
  