Test that sort, limit and filters work in batches
Clean up the code and logic, add comments