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 (closed) which is also fixed by this PR.
Fixes #5999 (closed) Fixes #6286 (closed) Fixes #6287 (closed)