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