add tests for and fix new type inference