[PLAT-4527] Bugfix to applyPaging and corresponding test; added pagedSearch, which takes paging into account more cleverly.