search pagination: add extensive tests for slicing + fix critical issues
Created by: slimsag
This PR fixes two critical issues with the search pagination API:
Fixes #6022 Fixes #6020
Additionally, I used TDD and added extensive tests for sliceSearchResults
which was the source of all the bugs I fixed here.
Test plan: see new tests added