Adding Unit Tests for message Encode and Decode
- fixes some error discover by unit testing