Added integration test for finding objects with sorted query.
Code cleanup.