Merge stderr and stdout when checking for timeouts

Fixes #146.

Beware of this code. I have only proven it right, not tested it. (C) Someone smarter than me.