You have to make sure you do your unrotating in the opposite order. Since the default is x,y,z - you need to do your un-rotations in the order of z,y,x. Negating the values should work with this.
So if your original is rotated 30, 60, 90... unrotate it zyx 90, 60, 30. Freeze transforms. Rotate forward xyz by 30, 60, 90.
The xform command has a flag for rotation order.
--JeffD