Some improvements and fixes

Hey dude!

I'm using your code on my project so I found some issues in the code.

To paginate the code, we need to sort, otherwise the paginated result is randomly.
I fixed the test, now everything is ok.

Cheers :smile: