refine channels and add unit tests
Merge branch 'master'