Improve type support
Add tests for type system