The braces ({ ... }) are directives in XQuery to evaluate their contents. If you look at what your working attempt actually stored, you will probably see that the fn:concat() function was evaluated. Similarly, in your first attempt, the reference to $content is being evaluated, but the declaration, outside the braces, is not evaluated and so is unavailable.
You need to escape the braces by doubling them: {{ ... }}.
I am not sure what you are doing with the <module> element, however. It’s not a construct I’ve ever seen, and I get an error trying to use an XQuery module that is not plain text. I recommend defining the module content as a string and inserting that.