Fixing command exec to support no-tty.
Adding test for command exec.