[backport] Use a Job when reading classpath markers in test.

The source of flaky tests was race condition in the classpath validator:
* one thread removed the old markers and adds the new ones
* the test thread waits until it finds a marker (which can happen before they are
removed) and reads them again for validation (which can happen between 'delete'
and 'add')

The proper solution is to put the test reads inside a `Job` that is scheduled
on the same resource (the project), leading to proper synchronization.(cherry picked from commit 7596e4ca9fa76e55c01fa08c5bbedbed9f553634)