[test_utils] Add tests for encode_compat_str