added coverage tests and bug fix