Added JUnit tests and Comments

…and some small fixes for bugs that the JUnit tests found