improved test coverage and fixed defect