Add a decorator for checking channel openness.

This decorator will be used in future commits.
Use the new decorator and remove repeated code.