pyexpect: add some debug logging; fix small bugs; change 'expect' method behaviour