Fixes #622
Migration and fixing tests for #622