Add unit test for public channel  and fix some bugs