Fix incorrect atomics codegen introduced in r154705, and extend test to catch it.