Small improvements to type handling
Tests for type analysis