Added tests for converting legacy databases; few bugfixes in legacy database handling