Add generic method to centralize Interlocked pattern, minor change to tests