write unit tests for the retry loop and for behaviour when errors occur during implementation.