Implemented server-side sorting

Refactored the server query execution a little. Beefed up the unit
test framework as well, installing a virtualenv to manage
dependencies.