fix terminal.py test
move io to fmtstr library

factor out everything that shouldn't be merged with bpython