adding unit test, cleaning up io