Refactored token checking and generation logic to the strategy, added factories and tests