Tests and fixed typechecker

Test Plan:
<see below>