Bring some sanity to group dir values

By fixing the logic and adding tests
Actually remove template node from AST