Refactoring of counter main to test