The atan2(y,x) equation results in heading = 0 degrees when the sensor is level, with Z up and the X axis pointing magnetic North. Use atan2(x,y) for Y North. The direction of rotation will change.
Check the BNO085 data sheet for the definition of the absolute orientation vector.