Merge pull request #1879 from antmicro/fix-race-condition

Fix race condition