server: add unit tests

Make test coverage >= 90%

#1019 
@jonboulle What would you like to see instead?