Use pexpect-based tests for testing shells

May fix #931.