More fixes and junit test cases