Add support for pexpect
Fix timeout handling