Made a test for #1 and made it pass by:

* looking for nested <script> in the loaded template and add those to the main document separately
* not adding the "containing" template to the document if there's only whitespace left after removing the nested <script>s