Fix rotation matrix bug found by Alex

There was a one-liner fix for that in a previous pull request that we closed, so now I bring it back. I also added a regression test so that the case that failed is now tested and won't fail again as long as we remember to run the tests regularly.