Template element clone node

Fix issues with cloneNode and importNode for HTMLTemplateElement

Refactor the code to share the implementation.