refactored count abstract class and test