improved coverage and more refactoring