Add unit test for dispatch register and unregister