fixing some issues raised by sonar and some tests added