update testcases for Issue #769 and #888
encode logic for issue # 888 and update utils tests
adapt testcase for issue #888