Add tests for paginating the history endpoint, and bugfix