Migration test for AtomicReference

Lines 35-39 and 41-45 are very similar. This duplication could be avoided by moving them into a separate method. Test would be shorter as well.