anchor.diff:          fun(_) -> application:stop(gproc) end,
           [?_test(register_case()),
            ?_test(server_registers_case()),
  -         ?_test(initial_ordering_case()),
  -         ?_test(empty_ordering_case()),
  -         ?_test(init_pieceset_case()),
  -         ?_test(one_available_case()),
  -         ?_test(decrement_on_exit_case()),
  -         ?_test(init_watch_case()),
  -         ?_test(add_peer_update_case()),
  -         ?_test(add_piece_update_case()),
  -         ?_test(peer_exit_update_case()),
  -         ?_test(local_unwatch_case())]}.
  +         ?_test(initial_ordering_case(test_data(2))),
  +         ?_test(empty_ordering_case(test_data(3))),
  +         ?_test(init_pieceset_case(test_data(4))),
  +         ?_test(one_available_case(test_data(5))),
  +         ?_test(decrement_on_exit_case(test_data(6))),
  +         ?_test(init_watch_case(test_data(7))),
  +         ?_test(add_peer_update_case(test_data(8))),
  +         ?_test(add_piece_update_case(test_data(9))),
  +         ?_test(aggregate_update_case(test_data(12))),
  +         ?_test(noaggregate_update_case(test_data(13))),
  +         ?_test(peer_exit_update_case(test_data(10))),
  +         ?_test(local_unwatch_case(test_data(11)))]}.
  +
  +test_data(N) ->
  +    {ok, Time} = ?timer:start_link(queue),
  +    {ok, Pid} = ?scarcity:start_link(N, Time),
  +    {N, Time, Pid}.
   
   register_case() ->
       true = ?scarcity:register_scarcity_server(0),
  
positive.code: -include_lib("eunit/include/eunit.hrl").
  -define(scarcity, ?MODULE).
  -define(pieceset, etorrent_pieceset).
  
  pieces(Pieces) ->
      ?pieceset:from_list(Pieces, 8).
  
negative.code:     receive done -> ok end,
      {ok, Ref, _} = ?scarcity:watch(10, ten, pieces([0,2,4,6])),
      Pid ! die,
      ?assertEqual(1, ?timer:fire(Time)),
      receive
          {scarcity, Ref, ten, Order} ->
              ?assertEqual([0,2,4,6], Order)
      end.
  
  local_unwatch_case({N, Time, Pid}) ->
      {ok, Ref, _} = ?scarcity:watch(11, eleven, pieces([0,2,4,6])),
      ?assertEqual(ok, ?scarcity:unwatch(11, Ref)),
      ok = ?scarcity:add_peer(11, pieces([0,1,2,3,4,5,6,7])),
  