refactoring + some coverage