updated data types and associated unit test.

Hi Shaun,

I've updated the encoding and decoding of the data types, could you please review the change? 

Thanks

Shuang