util: Fix pagination

The util.pages_list function returns the list of page numbers to display
in the paginator.

It was broken in a few ways, mainly in that it would return negative
page numbers in some cases.