search pagination: add more tests & fix bugs
Created by: slimsag
After this PR, all of the complex logic in the search pagination API (planning and slicing) is covered by tests extensively. The addition of the tests in this PR caught one off-by-one issue #6286 which is also fixed by this PR.
Fixes #5999 Fixes #6286 Fixes #6287