Various improvements to Pagination code and tests, cleanup