Factored the fixing functionality into a new module and added tests.