Fixed sonar issues. Tests added.