Improve transformation and tests