Refactor InvokeOp + fix tests