Rewrote unit-tests with using AtomicReference.