Fix stdin

A better solution for #410. The `process.env.isTTY` is used because when running tests it doesn't run them as a TTY and therefore they wont work correctly without settings this env flag.