fix bugged type conversion, add better type conversion unit test