Add JUnit test and correction