Add tests for ungrammatical tree patterns. Fixes #413