fix transformation and inverse
formatting
add test cases
Merge pull request #170.