Querying with pagination corrections and tests.