I know what you mean, and I can try to give you an explanation. Please excuse my bad english. Imagine your 3 dimensional vectors X,Y,Z as lines in space. Y facing up, X pointing to your right and Z to the front of you. Now if you rotate your object by 90 degrees clockwise along the Y axis, all the sudden, X is pointing behind you and Z to your right. This is why your object will seem to rotate arround the Z axis instead of X axis and vice versa.
The way to handle this would be to create your cube, and another invisible object (we will call it tilt object). Glue those two objects together using the glue object to limb command. Only use the tilt object (invisible one) to do the Y axis rotation and your cube to handle X and Z rotation.
I'll try to fix a piece of code quickly and post it.