Fixed some sonar warnings and added a unit test
Fixed some sonar warnings and added a unit test