Issue#769: implement encode logic; adapt old testcase and add new for Utils function