Fixed errors with the grammar and added tests.