schema tree BUGFIX actually implement modules if needed
diff --git a/src/tree_schema_helpers.c b/src/tree_schema_helpers.c
index f101c4f..0211da0 100644
--- a/src/tree_schema_helpers.c
+++ b/src/tree_schema_helpers.c
@@ -879,7 +879,11 @@
      */
     if (implement) {
         /* mark the module implemented, check for collision was already done */
-        (*mod)->implemented = 1;
+        ret = lys_set_implemented(*mod, features);
+        if (ret) {
+            *mod = NULL;
+            return ret;
+        }
     }
 
     return LY_SUCCESS;