Refactored Server, added tests of server.