mkdir is asynchronous, need to make it sync

Using asynchronous fs.mkdir as if it was synchronous leads to race conditions in the code. Please, fix it.