add javadoc, exceptions, JUnit testing and IO