Add quote mustache either side and prior to template set msg.quotes depending if global is a string.
e.g.
[{"id":"3ca9710f86c46a79","type":"inject","z":"b9860b4b9de8c8da","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":560,"y":520,"wires":[["99639618049b79b1"]]},{"id":"99639618049b79b1","type":"change","z":"b9860b4b9de8c8da","name":"","rules":[{"t":"set","p":"test","pt":"global","to":"{\"Path\":{\"A\": \"FolderA\",\"B\": \"FolderB\",\"length\":[350,500],\"test1\": 70389,\"test2\": 13546},\"testing\":{\"Refresh\": \"default\",\"Errors\": 5}}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":580,"wires":[["07b2e786018c81df","45a4da5325d30a72"]]},{"id":"07b2e786018c81df","type":"change","z":"b9860b4b9de8c8da","name":"","rules":[{"t":"set","p":"quotes","pt":"msg","to":"$type($globalContext(\"test.testing.Refresh\")) = \"string\" ? '\"' : ''","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":720,"y":560,"wires":[["813a7d96abfecabf"]]},{"id":"45a4da5325d30a72","type":"change","z":"b9860b4b9de8c8da","name":"","rules":[{"t":"set","p":"quotes","pt":"msg","to":"$type($globalContext(\"global.test.Path.test2\")) = \"string\" ? '\"' : ''","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":700,"y":620,"wires":[["9006aee5fa9b7656"]]},{"id":"813a7d96abfecabf","type":"template","z":"b9860b4b9de8c8da","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"#!/usr/bin/env\ntest = {{{quotes}}}{{{global.test.testing.Refresh}}}{{{quotes}}}\nprint (test)\nexit()\n","output":"str","x":880,"y":560,"wires":[["fd1f321c74387065"]]},{"id":"9006aee5fa9b7656","type":"template","z":"b9860b4b9de8c8da","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"#!/usr/bin/env\ntest = {{{quotes}}}{{{global.test.Path.test2}}}{{{quotes}}}\nprint (test)\nexit()\n","output":"str","x":860,"y":620,"wires":[["540728c240447648"]]},{"id":"fd1f321c74387065","type":"debug","z":"b9860b4b9de8c8da","name":"debug 332","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1090,"y":540,"wires":[]},{"id":"540728c240447648","type":"debug","z":"b9860b4b9de8c8da","name":"debug 333","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1070,"y":600,"wires":[]}]
Probably easier to get option 2 working though.