Small refactoring and additional testing to up coverage.