server: add unit tests

Make test coverage >= 90%

#1019 
@unihorn can we check the id of reg and trig?