Ensure consistent results when using limit and offset.
Also check for undefined orderBy
Merge pull request #1451 from bendiy/master

Ensure consistent results when using limit and offset. 2