JUnit testing with a couple bug fixes and documentation