Fix random tests & Modifications for Sonar