addressing various violations mentioned in Sonar and added more unit tests