Fix semantics of atomic operations: they should return the old value, not the new one