adding tests, cleaning things up
overridable internal io