Fixed precedences so that function definitions work.
Added two tests.