Small refactor and added a test
Fixed unintentionally disabled recovery code