Use paging for queries
Add test for paged_query