Gives a way to smartly preserve query string

Hello,

After your (justified) comments on my precedent pull request which was breaking test (my bad obviously), I rewrite some things and refactor/add tests.

I use your app to sort / paginate search results. So I need to preserve the querystring (search criteria) while I change the sorting.

I hope this version will look better for you!

Florent