more refactoring for proper testing