refined the server side code a little bit, and wrote more tests for the server