Tests and code for merging the channels