Fix bug in typechecker + test case.