Added better tests for retry logic, found a bug in impl