fixed pagination, added test