added a testMode flag and function.