schema tree REFACTOR evaluate features during compilation

So that the compiled schema tree reflects the state
of all the features.
diff --git a/tests/utests/data/test_diff.c b/tests/utests/data/test_diff.c
index c1a1cf2..f29e80d 100644
--- a/tests/utests/data/test_diff.c
+++ b/tests/utests/data/test_diff.c
@@ -227,7 +227,7 @@
     (*state) = st = calloc(1, sizeof *st);
     assert_non_null(st);
     assert_int_equal(LY_SUCCESS, ly_ctx_new(TESTS_DIR_MODULES_YANG, 0, &st->ctx));
-    assert_non_null(ly_ctx_load_module(st->ctx, "ietf-netconf-acm", "2018-02-14"));
+    assert_non_null(ly_ctx_load_module(st->ctx, "ietf-netconf-acm", "2018-02-14", NULL));
     assert_int_equal(LY_SUCCESS, lys_parse_mem(st->ctx, schema, LYS_IN_YANG, NULL));
 
     return 0;
diff --git a/tests/utests/data/test_lyb.c b/tests/utests/data/test_lyb.c
index 588ad22..91117f0 100644
--- a/tests/utests/data/test_lyb.c
+++ b/tests/utests/data/test_lyb.c
@@ -280,8 +280,8 @@
     "</interfaces>";
 
 
-    assert_non_null(ly_ctx_load_module(st->ctx, "ietf-ip", NULL));
-    assert_non_null(ly_ctx_load_module(st->ctx, "iana-if-type", NULL));
+    assert_non_null(ly_ctx_load_module(st->ctx, "ietf-ip", NULL, NULL));
+    assert_non_null(ly_ctx_load_module(st->ctx, "iana-if-type", NULL, NULL));
 
     assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, data_xml, LYD_XML, LYD_PARSE_ONLY, 0, &st->dt1));
     assert_ptr_not_equal(st->dt1, NULL);
@@ -328,7 +328,7 @@
     "</cont>";
 
     assert_int_equal(LY_SUCCESS, lys_parse_mem(st->ctx, origin_yang, LYS_IN_YANG, NULL));
-    lys_set_implemented(ly_ctx_get_module_latest(st->ctx, "ietf-origin"));
+    lys_set_implemented(ly_ctx_get_module_latest(st->ctx, "ietf-origin"), NULL);
 
     assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, data_xml, LYD_XML, LYD_PARSE_ONLY, 0, &st->dt1));
     assert_ptr_not_equal(st->dt1, NULL);
diff --git a/tests/utests/data/test_parser_json.c b/tests/utests/data/test_parser_json.c
index 0c9e0a2..c22eb66 100644
--- a/tests/utests/data/test_parser_json.c
+++ b/tests/utests/data/test_parser_json.c
@@ -77,15 +77,15 @@
             "leaf foo3 { type uint32; }"
             "notification n2;}";
     const struct lys_module *mod;
+    const char *feats[] = {"writable-running", NULL};
 
 #if ENABLE_LOGGER_CHECKING
     ly_set_log_clb(logger, 1);
 #endif
 
     assert_int_equal(LY_SUCCESS, ly_ctx_new(TESTS_DIR_MODULES_YANG, 0, &ctx));
-    assert_non_null(ly_ctx_load_module(ctx, "ietf-netconf-with-defaults", "2011-06-01"));
-    assert_non_null((mod = ly_ctx_load_module(ctx, "ietf-netconf", "2011-06-01")));
-    assert_int_equal(LY_SUCCESS, lys_feature_enable(mod, "writable-running"));
+    assert_non_null((mod = ly_ctx_load_module(ctx, "ietf-netconf", "2011-06-01", feats)));
+    assert_non_null(ly_ctx_load_module(ctx, "ietf-netconf-with-defaults", "2011-06-01", NULL));
     assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, schema_a, LYS_IN_YANG, NULL));
 
     return 0;
diff --git a/tests/utests/data/test_parser_xml.c b/tests/utests/data/test_parser_xml.c
index 183e22f..baf4608 100644
--- a/tests/utests/data/test_parser_xml.c
+++ b/tests/utests/data/test_parser_xml.c
@@ -75,15 +75,15 @@
             "leaf foo3 { type uint32; }"
             "notification n2;}";
     const struct lys_module *mod;
+    const char *feats[] = {"writable-running", NULL};
 
 #if ENABLE_LOGGER_CHECKING
     ly_set_log_clb(logger, 1);
 #endif
 
     assert_int_equal(LY_SUCCESS, ly_ctx_new(TESTS_DIR_MODULES_YANG, 0, &ctx));
-    assert_non_null(ly_ctx_load_module(ctx, "ietf-netconf-with-defaults", "2011-06-01"));
-    assert_non_null((mod = ly_ctx_load_module(ctx, "ietf-netconf", "2011-06-01")));
-    assert_int_equal(LY_SUCCESS, lys_feature_enable(mod, "writable-running"));
+    assert_non_null((mod = ly_ctx_load_module(ctx, "ietf-netconf", "2011-06-01", feats)));
+    assert_non_null(ly_ctx_load_module(ctx, "ietf-netconf-with-defaults", "2011-06-01", NULL));
     assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, schema_a, LYS_IN_YANG, NULL));
 
     return 0;
diff --git a/tests/utests/data/test_printer_xml.c b/tests/utests/data/test_printer_xml.c
index b2bcd75..75cddd2 100644
--- a/tests/utests/data/test_printer_xml.c
+++ b/tests/utests/data/test_printer_xml.c
@@ -131,7 +131,7 @@
 #endif
 
     assert_int_equal(LY_SUCCESS, ly_ctx_new(TESTS_DIR_MODULES_YANG, 0, &s->ctx));
-    assert_non_null(ly_ctx_load_module(s->ctx, "ietf-netconf-with-defaults", "2011-06-01"));
+    assert_non_null(ly_ctx_load_module(s->ctx, "ietf-netconf-with-defaults", "2011-06-01", NULL));
     assert_int_equal(LY_SUCCESS, lys_parse_mem(s->ctx, schema_a, LYS_IN_YANG, NULL));
     assert_int_equal(LY_SUCCESS, lys_parse_mem(s->ctx, schema_b, LYS_IN_YANG, NULL));
     assert_int_equal(LY_SUCCESS, lys_parse_mem(s->ctx, schema_c, LYS_IN_YANG, NULL));
diff --git a/tests/utests/data/test_types.c b/tests/utests/data/test_types.c
index 27e2338..e17118d 100644
--- a/tests/utests/data/test_types.c
+++ b/tests/utests/data/test_types.c
@@ -184,8 +184,7 @@
     assert_string_equal("15", leaf->value.canonical);
     assert_int_equal(15, leaf->value.int8);
 
-    value.realtype = leaf->value.realtype;
-    assert_int_equal(LY_SUCCESS, value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
+    assert_int_equal(LY_SUCCESS, leaf->value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
     assert_string_equal(leaf->value.canonical, value.canonical);
     assert_int_equal(15, value.int8);
     value.realtype->plugin->free(s->ctx, &value);
@@ -225,8 +224,7 @@
     assert_string_equal("150", leaf->value.canonical);
     assert_int_equal(150, leaf->value.uint8);
 
-    value.realtype = leaf->value.realtype;
-    assert_int_equal(LY_SUCCESS, value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
+    assert_int_equal(LY_SUCCESS, leaf->value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
     assert_string_equal(leaf->value.canonical, value.canonical);
     assert_int_equal(150, value.uint8);
     value.realtype->plugin->free(s->ctx, &value);
@@ -266,8 +264,7 @@
     assert_string_equal("8.0", leaf->value.canonical);
     assert_int_equal(80, leaf->value.dec64);
 
-    value.realtype = leaf->value.realtype;
-    assert_int_equal(LY_SUCCESS, value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
+    assert_int_equal(LY_SUCCESS, leaf->value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
     assert_string_equal(leaf->value.canonical, value.canonical);
     assert_int_equal(80, value.dec64);
     value.realtype->plugin->free(s->ctx, &value);
@@ -374,8 +371,7 @@
     assert_string_equal("zero", leaf->value.bits_items[0]->name);
     assert_string_equal("two", leaf->value.bits_items[1]->name);
 
-    value.realtype = leaf->value.realtype;
-    assert_int_equal(LY_SUCCESS, value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
+    assert_int_equal(LY_SUCCESS, leaf->value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
     assert_string_equal(leaf->value.canonical, value.canonical);
     assert_int_equal(2, LY_ARRAY_COUNT(value.bits_items));
     assert_string_equal("zero", value.bits_items[0]->name);
@@ -389,29 +385,17 @@
     assert_string_equal("bits", tree->schema->name);
     leaf = (struct lyd_node_term*)tree;
     assert_string_equal("zero two", leaf->value.canonical);
+
+    assert_int_equal(LY_SUCCESS, leaf->value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
+    assert_string_equal(leaf->value.canonical, value.canonical);
+    assert_int_equal(2, LY_ARRAY_COUNT(value.bits_items));
+    assert_string_equal("zero", value.bits_items[0]->name);
+    value.realtype->plugin->free(s->ctx, &value);
     lyd_free_all(tree);
 
     /* disabled feature */
     TEST_DATA("<bits xmlns=\"urn:tests:types\"> \t one \n\t </bits>", LY_EVALID, "Bit \"one\" is disabled by its 1. if-feature condition. /types:bits");
 
-    /* enable that feature */
-    assert_int_equal(LY_SUCCESS, lys_feature_enable(ly_ctx_get_module(s->ctx, "types", NULL), "f"));
-    TEST_DATA("<bits xmlns=\"urn:tests:types\"> \t one \n\t </bits>", LY_SUCCESS, "");
-    assert_int_equal(LYS_LEAF, tree->schema->nodetype);
-    assert_string_equal("bits", tree->schema->name);
-    leaf = (struct lyd_node_term*)tree;
-    assert_string_equal("one", leaf->value.canonical);
-    assert_int_equal(1, LY_ARRAY_COUNT(leaf->value.bits_items));
-    assert_string_equal("one", leaf->value.bits_items[0]->name);
-
-    value.realtype = leaf->value.realtype;
-    assert_int_equal(LY_SUCCESS, value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
-    assert_string_equal(leaf->value.canonical, value.canonical);
-    assert_int_equal(1, LY_ARRAY_COUNT(value.bits_items));
-    assert_string_equal("one", value.bits_items[0]->name);
-    value.realtype->plugin->free(s->ctx, &value);
-    lyd_free_all(tree);
-
     /* multiple instances of the bit */
     TEST_DATA("<bits xmlns=\"urn:tests:types\">one zero one</bits>", LY_EVALID, "Bit \"one\" used multiple times. /types:bits");
 
@@ -441,8 +425,7 @@
     assert_string_equal("white", leaf->value.canonical);
     assert_string_equal("white", leaf->value.enum_item->name);
 
-    value.realtype = leaf->value.realtype;
-    assert_int_equal(LY_SUCCESS, value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
+    assert_int_equal(LY_SUCCESS, leaf->value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
     assert_string_equal(leaf->value.canonical, value.canonical);
     assert_string_equal("white", value.enum_item->name);
     value.realtype->plugin->free(s->ctx, &value);
@@ -452,15 +435,6 @@
     TEST_DATA("<enums xmlns=\"urn:tests:types\">yellow</enums>", LY_EVALID,
               "Enumeration \"yellow\" is disabled by its 1. if-feature condition. /types:enums");
 
-    /* enable that feature */
-    assert_int_equal(LY_SUCCESS, lys_feature_enable(ly_ctx_get_module(s->ctx, "types", NULL), "f"));
-    TEST_DATA("<enums xmlns=\"urn:tests:types\">yellow</enums>", LY_SUCCESS, "");
-    assert_int_equal(LYS_LEAF, tree->schema->nodetype);
-    assert_string_equal("enums", tree->schema->name);
-    leaf = (struct lyd_node_term*)tree;
-    assert_string_equal("yellow", leaf->value.canonical);
-    lyd_free_all(tree);
-
     /* leading/trailing whitespaces are not valid */
     TEST_DATA("<enums xmlns=\"urn:tests:types\"> white</enums>", LY_EVALID, "Invalid enumeration value \" white\". /types:enums");
     TEST_DATA("<enums xmlns=\"urn:tests:types\">white\n</enums>", LY_EVALID, "Invalid enumeration value \"white\n\". /types:enums");
@@ -495,8 +469,7 @@
     leaf = (struct lyd_node_term*)tree;
     assert_string_equal("TQ==", leaf->value.canonical);
 
-    value.realtype = leaf->value.realtype;
-    assert_int_equal(LY_SUCCESS, value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
+    assert_int_equal(LY_SUCCESS, leaf->value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
     assert_string_equal(leaf->value.canonical, value.canonical);
     value.realtype->plugin->free(s->ctx, &value);
     memset(&value, 0, sizeof value);
@@ -663,8 +636,7 @@
     assert_string_equal("gigabit-ethernet", leaf->value.ident->name);
     test_printed_value(&leaf->value, "t:gigabit-ethernet", LY_PREF_SCHEMA, s->mod_types->parsed);
 
-    value.realtype = leaf->value.realtype;
-    assert_int_equal(LY_SUCCESS, value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
+    assert_int_equal(LY_SUCCESS, leaf->value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
     assert_string_equal("types:gigabit-ethernet", value.canonical);
     assert_string_equal("gigabit-ethernet", value.ident->name);
     value.realtype->plugin->free(s->ctx, &value);
@@ -729,8 +701,7 @@
     assert_string_equal("leaftarget", leaf->value.target[1].node->name);
     assert_null(leaf->value.target[1].predicates);
 
-    value.realtype = leaf->value.realtype;
-    assert_int_equal(LY_SUCCESS, value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
+    assert_int_equal(LY_SUCCESS, leaf->value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
     assert_string_equal("/types:cont/leaftarget", value.canonical);
     assert_true(LY_ARRAY_COUNT(leaf->value.target) == LY_ARRAY_COUNT(value.target));
     assert_true(leaf->value.target[0].node == value.target[0].node);
@@ -776,8 +747,7 @@
     test_printed_value(&leaf->value, "/t:list_inst[t:id=\"/t:leaflisttarget[.='b']\"]/t:value", LY_PREF_SCHEMA, s->mod_types->parsed);
     test_printed_value(&leaf->value, "/types:list_inst[id=\"/types:leaflisttarget[.='b']\"]/value", LY_PREF_JSON, NULL);
 
-    value.realtype = leaf->value.realtype;
-    assert_int_equal(LY_SUCCESS, value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
+    assert_int_equal(LY_SUCCESS, leaf->value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
     assert_string_equal("/types:list_inst[id=\"/types:leaflisttarget[.='b']\"]/value", value.canonical);
     assert_true(LY_ARRAY_COUNT(leaf->value.target) == LY_ARRAY_COUNT(value.target));
     assert_true(leaf->value.target[0].node == value.target[0].node);
@@ -1115,8 +1085,7 @@
 
     test_printed_value(&leaf->value, "12", LY_PREF_SCHEMA, NULL);
 
-    value.realtype = leaf->value.realtype;
-    assert_int_equal(LY_SUCCESS, value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
+    assert_int_equal(LY_SUCCESS, leaf->value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
     assert_string_equal("12", value.canonical);
     assert_non_null(value.subvalue->prefix_data);
     assert_int_equal(((struct ly_set *)leaf->value.subvalue->prefix_data)->count, 0);
@@ -1153,8 +1122,7 @@
     test_printed_value(&leaf->value, "d:fast-ethernet", LY_PREF_SCHEMA, s->mod_defs->parsed);
     test_printed_value(&leaf->value.subvalue->value, "d:fast-ethernet", LY_PREF_SCHEMA, s->mod_defs->parsed);
 
-    value.realtype = leaf->value.realtype;
-    assert_int_equal(LY_SUCCESS, value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
+    assert_int_equal(LY_SUCCESS, leaf->value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
     assert_string_equal("defs:fast-ethernet", value.canonical);
     assert_string_equal("defs:fast-ethernet", value.subvalue->value.canonical);
     assert_non_null(value.subvalue->prefix_data);
diff --git a/tests/utests/data/test_validation.c b/tests/utests/data/test_validation.c
index 072c375..66299f2 100644
--- a/tests/utests/data/test_validation.c
+++ b/tests/utests/data/test_validation.c
@@ -412,13 +412,15 @@
                 "type string;"
             "}"
         "}";
+    struct ly_in *in;
+    const char *feats[] = {"feat1", NULL};
 
 #if ENABLE_LOGGER_CHECKING
     ly_set_log_clb(logger, 1);
 #endif
 
     assert_int_equal(LY_SUCCESS, ly_ctx_new(TESTS_DIR_MODULES_YANG, 0, &ctx));
-    assert_non_null(ly_ctx_load_module(ctx, "ietf-netconf-with-defaults", "2011-06-01"));
+    assert_non_null(ly_ctx_load_module(ctx, "ietf-netconf-with-defaults", "2011-06-01", NULL));
     assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, schema_a, LYS_IN_YANG, NULL));
     assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, schema_b, LYS_IN_YANG, NULL));
     assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, schema_c, LYS_IN_YANG, NULL));
@@ -428,7 +430,9 @@
     assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, schema_g, LYS_IN_YANG, NULL));
     assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, schema_h, LYS_IN_YANG, NULL));
     assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, schema_i, LYS_IN_YANG, NULL));
-    assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, schema_j, LYS_IN_YANG, NULL));
+    assert_int_equal(LY_SUCCESS, ly_in_new_memory(schema_j, &in));
+    assert_int_equal(LY_SUCCESS, lys_parse(ctx, in, LYS_IN_YANG, feats, NULL));
+    ly_in_free(in, 0);
 
     return 0;
 }
@@ -1225,112 +1229,6 @@
 }
 
 static void
-test_iffeature(void **state)
-{
-    *state = test_iffeature;
-
-    const char *data;
-    struct lyd_node *tree;
-    const struct lys_module *mod = ly_ctx_get_module_latest(ctx, "g");
-
-    /* get empty data */
-    tree = NULL;
-    assert_int_equal(lyd_validate_module(&tree, mod, 0, NULL), LY_SUCCESS);
-    assert_null(tree);
-
-    /* disabled by f1 */
-    data =
-    "<cont xmlns=\"urn:tests:g\">"
-        "<d>51</d>"
-    "</cont>";
-    assert_int_equal(LY_EVALID, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
-    assert_null(tree);
-    logbuf_assert("Data are disabled by \"cont\" schema node if-feature. /g:cont");
-
-    /* enable f1 */
-    assert_int_equal(lys_feature_enable(mod, "f1"), LY_SUCCESS);
-
-    /* get data with default container */
-    assert_int_equal(lyd_validate_module(&tree, mod, 0, NULL), LY_SUCCESS);
-    assert_non_null(tree);
-    lyd_free_siblings(tree);
-
-    /* disabled by f2 */
-    data =
-    "<cont xmlns=\"urn:tests:g\">"
-        "<cont2>"
-            "<e>val</e>"
-        "</cont2>"
-    "</cont>";
-    assert_int_equal(LY_EVALID, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
-    assert_null(tree);
-    logbuf_assert("Data are disabled by \"cont2\" schema node if-feature. /g:cont/cont2");
-
-    data =
-    "<cont xmlns=\"urn:tests:g\">"
-        "<a>val</a>"
-    "</cont>";
-    assert_int_equal(LY_EVALID, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
-    assert_null(tree);
-    logbuf_assert("Data are disabled by \"choic\" schema node if-feature. /g:cont/a");
-
-    /* enable f3 */
-    assert_int_equal(lys_feature_enable(mod, "f3"), LY_SUCCESS);
-
-    assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
-    assert_non_null(tree);
-    lyd_free_siblings(tree);
-
-    /* disabled by f2 */
-    data =
-    "<cont xmlns=\"urn:tests:g\">"
-        "<l>val</l>"
-    "</cont>";
-    assert_int_equal(LY_EVALID, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
-    assert_null(tree);
-    logbuf_assert("Data are disabled by \"b\" schema node if-feature. /g:cont/l");
-
-    /* enable f2 */
-    assert_int_equal(lys_feature_enable(mod, "f2"), LY_SUCCESS);
-
-    assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
-    assert_non_null(tree);
-    lyd_free_siblings(tree);
-
-    /* try separate validation */
-    assert_int_equal(lys_feature_disable(mod, "f1"), LY_SUCCESS);
-    assert_int_equal(lys_feature_disable(mod, "f2"), LY_SUCCESS);
-    assert_int_equal(lys_feature_disable(mod, "f3"), LY_SUCCESS);
-
-    data =
-    "<cont xmlns=\"urn:tests:g\">"
-        "<l>val</l>"
-        "<d>51</d>"
-        "<cont2>"
-            "<e>val</e>"
-        "</cont2>"
-    "</cont>";
-    assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, LYD_PARSE_ONLY, 0, &tree));
-    assert_non_null(tree);
-
-    assert_int_equal(LY_EVALID, lyd_validate_all(&tree, NULL, LYD_VALIDATE_PRESENT, NULL));
-    logbuf_assert("Data are disabled by \"cont\" schema node if-feature. /g:cont");
-
-    assert_int_equal(lys_feature_enable(mod, "f1"), LY_SUCCESS);
-
-    assert_int_equal(LY_EVALID, lyd_validate_all(&tree, NULL, LYD_VALIDATE_PRESENT, NULL));
-    logbuf_assert("Data are disabled by \"b\" schema node if-feature. /g:cont/l");
-
-    assert_int_equal(lys_feature_enable(mod, "f2"), LY_SUCCESS);
-
-    assert_int_equal(LY_SUCCESS, lyd_validate_all(&tree, NULL, LYD_VALIDATE_PRESENT, NULL));
-
-    lyd_free_siblings(tree);
-
-    *state = NULL;
-}
-
-static void
 test_state(void **state)
 {
     *state = test_state;
@@ -1400,7 +1298,6 @@
     const char *data;
     struct ly_in *in;
     struct lyd_node *tree, *op_tree;
-    const struct lys_module *mod;
 
     data =
     "<cont xmlns=\"urn:tests:j\">"
@@ -1429,14 +1326,6 @@
     assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, LYD_PARSE_ONLY | LYD_PARSE_TRUSTED, 0, &tree));
     assert_non_null(tree);
 
-    /* disabled if-feature */
-    assert_int_equal(LY_EVALID, lyd_validate_op(op_tree, tree, LYD_VALIDATE_OP_RPC, NULL));
-    logbuf_assert("Data are disabled by \"act\" schema node if-feature. /j:cont/l1[k='val1']/act");
-
-    mod = ly_ctx_get_module_latest(ctx, "j");
-    assert_non_null(mod);
-    assert_int_equal(LY_SUCCESS, lys_feature_enable(mod, "feat1"));
-
     /* input must false */
     assert_int_equal(LY_EVALID, lyd_validate_op(op_tree, tree, LYD_VALIDATE_OP_RPC, NULL));
     logbuf_assert("Must condition \"../../lf1 = 'true'\" not satisfied. /j:cont/l1[k='val1']/act");
@@ -1453,7 +1342,6 @@
     /* success */
     assert_int_equal(LY_SUCCESS, lyd_validate_op(op_tree, tree, LYD_VALIDATE_OP_RPC, NULL));
 
-    lys_feature_disable(mod, "feat1");
     lyd_free_tree(op_tree);
     lyd_free_siblings(tree);
 
@@ -1468,7 +1356,6 @@
     const char *data;
     struct ly_in *in;
     struct lyd_node *tree, *op_tree, *request;
-    const struct lys_module *mod;
 
     data =
     "<cont xmlns=\"urn:tests:j\">"
@@ -1504,14 +1391,6 @@
     assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, LYD_PARSE_ONLY | LYD_PARSE_TRUSTED, 0, &tree));
     assert_non_null(tree);
 
-    /* disabled if-feature */
-    assert_int_equal(LY_EVALID, lyd_validate_op(op_tree, tree, LYD_VALIDATE_OP_REPLY, NULL));
-    logbuf_assert("Data are disabled by \"act\" schema node if-feature. /j:cont/l1[k='val1']/act");
-
-    mod = ly_ctx_get_module_latest(ctx, "j");
-    assert_non_null(mod);
-    assert_int_equal(LY_SUCCESS, lys_feature_enable(mod, "feat1"));
-
     /* input must false */
     assert_int_equal(LY_EVALID, lyd_validate_op(op_tree, tree, LYD_VALIDATE_OP_REPLY, NULL));
     logbuf_assert("Must condition \"../../lf1 = 'true2'\" not satisfied. /j:cont/l1[k='val1']/act");
@@ -1528,7 +1407,6 @@
     /* success */
     assert_int_equal(LY_SUCCESS, lyd_validate_op(op_tree, tree, LYD_VALIDATE_OP_REPLY, NULL));
 
-    lys_feature_disable(mod, "feat1");
     lyd_free_tree(op_tree);
     lyd_free_siblings(tree);
 
@@ -1545,7 +1423,6 @@
         cmocka_unit_test_teardown(test_unique_nested, teardown_s),
         cmocka_unit_test_teardown(test_dup, teardown_s),
         cmocka_unit_test_teardown(test_defaults, teardown_s),
-        cmocka_unit_test_teardown(test_iffeature, teardown_s),
         cmocka_unit_test_teardown(test_state, teardown_s),
         cmocka_unit_test_teardown(test_must, teardown_s),
         cmocka_unit_test_teardown(test_action, teardown_s),