How does Arducopter decides which way to roll from inverted

Using ArduCopter V4.3.3 with X type quad frame.
I have the quad on a small jig to see how to it behaves when switching between Acro and Stabilize.
When switching to Stabilize from Acro with pitch angle less than 90 degrees (un inverted) the copter balances itself nicely.
When switching to Stabilize from Acro with the quad inverted the behavior is strange:
It tries to become level while inverted (up-side-down), and just then it rolls to be leveled up-side-up.

I couldn’t find anything in the documentation that says it should act like that.
It feels to me that since the pitch value is always ±90 (and not ±180), ArduPilot tries the roll the quad towards the shortest route to level, but then it realizes it’s inverted…

Any help understanding what’s going on is appreciated!