Fix count method to work with select statement.
Add test for pagination with select statement.
Merge pull request #372 from edariedl/fix_count_with_select_statement

Fix count method to work with select statement.