Fix #1409

Find pending migrations and return them in getUndoneMigrations
Added test for actual execution
Merge pull request #2056 from komola/fix/1409

Fix #1409