fix stdin TTY check and tests
3.0.2