aggregator test: Extract a useful function from test_collect.