Refactored transposeData. Added tests to cover refactoring.