Added paging logic, preliminary unit tests