Changed to readline history that passes tests

This one closes stdin and reopens it as a tty, then points rl_instream
to that tty.  This version seems to follow more of what the code was
already doing, and it fixes the two broken unit tests.

I'm not exactly sure what broke them.  I think that the autosave was
getting pushed into the history based on the tty status of rl_instream,
but even with that theory I'm not clear on how the new logic fixes that.