Villages shouldn't trap themselves between walls when building double walls

Simular issue with flattening a mountain side for mining. Villagers would get stuck on it. And die there.
It cost me around 10 dead villagers to have it flat enough, so they could go down again.