Move the code to a class and unify it so we can also add coverage.
Move the code to a class and unify it so we can also add coverage.