More refactoring and unit test modification.