full test coverage some minor refactoring.