More refactoring and consilidation to simplify writing tests