Fixed the error and wrote tests to succesfully check that things work correctly.