Clean up templates and add some more tests