server: add unit tests

Make test coverage >= 90%
Merge pull request #1052 from unihorn/121

server: add unit tests