fix Compare and swap returns incorrect cause

issue #611
Please do not accept this because commits should be squashed with appropriate message

I would like to get some feedback on this.
I worry about modifications in v1 tests while v1 API is frozen.

Thank you!