DEV-002: fix creating templates.js before running tests, re-factor small code smells