Cleaning up the code.

Extracted a method out of common code segments in test cases used for
creating the sink, mem. channel and sending a message.