Adds pagination class and tests

Adds class and tests to handle pagination for a query.