I ran a calculation based on quaternion multiplication and the wiki article and the formula looks ok. I'll have to test your demos though to be completely sure ;)