This moves the transformation pass to the right location, and adds tests to see that it actually works correctly.