server: add unit tests

Make test coverage >= 90%

#1019 
this change is not consistent with the comment above.