avoid paginate count when no results
fix failing test
Merge pull request #1067 from ceeram/paginatecount

Avoid calling paginateCount when there are no results.