Removed global test variable and used AtomicInteger instead