[PATCH v3 1/2] test_firmware: prevent race conditions by a correct implementation of locking