Re-work pagination and add tests.

Here's a first version. This version doesn't include `next` or `previous` in the metadata if a number for page can't be found. This is only really expected to happen when `next` or `previous` are null for the first and last page. An alternative would be include `next` and `previous` in the metadata and set them to -1 for the first and last pages. What do you think?

I also still need to write user facing docs but I'm waiting for that to be setup.
In this first version I decided not to include `next` /  `previous` in the metadata when `page` doesn't exists. But it could also work like you suggest. Do you think having the `null` value in `next` / `previous` when `page` doesn't exist is better for applications?