Refactored transposeData. Added tests to cover refactoring.

Tidy up and make it testable.