pagination: use an iterator to be pythonic. added unit test