Fix converter bugs
Add unit test for type converter