Added specs for server
refactor server code