I think it's better to return earlier than fixing up counter, right after second opentype_get_typographic_features().
Also please adjust patch subject, features are filtered using script/locale arguments and default entries in the font, when available. So it's normal for this method to occasionally return 0, even though GSUB/GPOS is present.