Fixes #633

@lamblin . Unit tests to be added.
I don't understand this comment. 1/3 of the time, the values would still be the other way around.