Made the server side code modular and put in a few more meaningful tests, starting to understand it all a bit better now