The problem was that foreground lock wasn't held at all by the test. I've changed the test now, so that it acquires the lock on "initTestCase" and releases it again on "cleanupTestCase", this way it's held through the whole test.