cleared some sonar warnings and fixed a bug in junit test