Refactor pagination

It solves the problem described in #55.

It also creates the initial integration tests for users.