refactored to remove static and improved the unit test