Refactors Page#next_or_previous and adds more specs for it.