tests: move input-tty into a test-lib.sh function