Bug 1075227 - Implement chunking logic for faster tests runs on CI

I would have liked a test that we correctly get all files if we ask all chunks in a row (from an unsorted list).