Grammar testing + simplification of code