Move all TTY checks to a common util function and mock it for update tests.