Fix count method to work with select statement.
Add test for pagination with select statement.
Test against Rails 4.1.2