Add unit tests, more doc in templates