Fix issue #167 by passing the invariant function as the parent scope.