Fix failing tests by moving JS_DEBUG declaration to injected function