Fix deleting job artifact objects
This is a re-application of the original MR !128279 (merged) that was reverted (!128995 (merged)) because of a flaky spec.
In this MR, we only apply the actual fix and its unit test.
We have a separate MR (!129212) to address the specs improvement that was causing intermittent failures.
Resolves #419920 (closed)