Davidw pagination

I refactored out the computation and created a test file