Wait for channel to fully complete sending all data

Sometimes the channel has an exit status when we haven't received all of the stdout/ stderr.

This checks if the channel has exited, check if we have no stdout or stderr to receive. I've also moved it into a method for clarity.