Refactoring the output into a transform
Fixing tests
Adding preconditions