server: add unit tests

Make test coverage >= 90%

#1019 
i think we only need to test if the cancel function will trigger the wait gc and unblock the do function.