Repair import mistakes and fix tests to use moved code