add integration tests for paging and fix some bugs