Fix retry behavior with unit tests