feat: added some unit tests for code gen and decoder fix: backport some bugfix from chrisking1981 branch