There's two things that are happening:
Each piece has a rotation in X, Y, and Z between 0 and 360.
However, when you move the pieces by hand, a rotation of 360 gets changed to 0.
So Those pieces are rotating backwards 270 degrees when they should rotate forward 90.
Also, there's something called "Gimbal Lock".
(
http://www.youtube.com/watch?v=zc8b2Jo7mno, watch the video for a good visual explanation)
The way Euler rotations work, you first rotate something in the object's X axis, then the Y, then the Z.
The problem is that when you rotate along the X axis, the Y and Z axes rotate along with the object. And if you rotate the Y axis, the Z axis follows the object but the X doesn't. Most of the time, this doesn't cause a problem.
However, if you start with a 90 degree rotation in Y, you make it so that the X and Z axes are pointing the same direction. So with the X and Z pointing the same direction, and the Y pointing a second direction, there's no axis to twist for the third direction.
There's something called a quaternion rotation that fixes that problem. Unfortunately the numbers aren't really intuitive.