unifies tensor transpose code
const-ify code
better tests