Hi Chiel,
As I read the code, fun is defined within the module as Function[fvar,expr]. For this definition to be useful, fvar and expr need to be previously defined such that expr is the expression defining the functional relationship and fvar is a name for a variable which appears in the expression. For that reason, I would expect both values to be defined, probably in the arguments passed to the module. I see that expr is so defined, but fvar is not. This makes me suspect that var appearing as an argument for findRoot should read fvar.
It is possible your posted code was altered in the posting process. The best way to post Mathematica code is to use the method recommended here: Community Guidelines
Kind regards,
David