Sonar fixes and added test code