Functional test for pagination

Refactored various things