Fix for AMD

This fixes the AMD option.

We still require the namespace option enabled for AMD to export the templates back out as the AMD module.

This works for me, tested with a few templates, also added a test for AMD.