Tests/Fixes for undoing migrations.

Fixes #1210