The Dataloss Race Condition fixed

I wanted to create a unit test for bbde5a4eaf5a0aa6d2162e8df8b40b5f4e93c43a however it seems it just decrease the chance of partition moving, it doesn't eliminate it completely so I was not able to write a reliably test for this behaviour.  

The other two commits should prevent the dataloss.