properly simulate user input

and of course, add tests!