Use valid xml to configure policies.
In your examples one can find lines like this one:
<set-variable name="isMobile" value="@(context.Request.Headers["User-Agent"].Contains("iPad") || context.Request.Headers["User-Agent"].Contains("iPhone"))" />
If you try to validate this xml, you will find out that those double quotes inside of the value attribute are not allowed.
