server: add unit tests

Make test coverage >= 90%

#1019 
move this to tests struct.