Add tests, clarify exit status
Clean up template error handling