[backport 3.0.x] Added test to demonstrate correct locking when running `ProjectsCleanJob...

...`

The test is unfortunately rather cumbersome, but it does only pass after
reverting the commit SHA: 24ec637983d4afa24de23f91edcd353b6204bf35 (which
has been done in the previous commit).

The reason why the test isn't clean is that I couldn't find a simpler way
to be notified of 1) when a project's clean is finished, and 2) when an
uncaught exception occurs within a `Job`. If you happen to know a better
way to deal with it, please do contribute it.

Re #1001658
(cherry picked from commit ac97f1bf18633aaf725ec6477390d8a9c3def9d4)