enabled depth sorting for client.

Also refactored code to allow unit testing.
Merge branch 'master' of https://github.com/ZimonD/ContextCG7