fixing test adding coverage and cleaning up error handling