Rework code into a class
Rewrite tests to make use of created class