add more test coverage to twirl compiler; refactor some classes for better testing