fix arity/type checks

Also fix instance method invocation with an implicit "this". Also add
some tests.