libyang REFACTOR return values and options changes

Unified, all functions that return a variety
of errors return LY_ERR. Any options such as
NOSIBLINGS, WITHSIBLINGS and so on were replaced
by function variants with suffixes _single, _all,
_tree, and _siblings.
diff --git a/tests/utests/data/test_diff.c b/tests/utests/data/test_diff.c
index 612bf88..bb52594 100644
--- a/tests/utests/data/test_diff.c
+++ b/tests/utests/data/test_diff.c
@@ -228,7 +228,7 @@
     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(lys_parse_mem(st->ctx, schema, LYS_IN_YANG));
+    assert_int_equal(LY_SUCCESS, lys_parse_mem(st->ctx, schema, LYS_IN_YANG, NULL));
 
     return 0;
 }
@@ -263,9 +263,9 @@
     assert_non_null(st->first);
     st->second = NULL;
 
-    assert_int_equal(lyd_diff(st->first, lyd_node_children(st->first, 0), 0, &st->diff1), LY_EINVAL);
+    assert_int_equal(lyd_diff_siblings(st->first, lyd_node_children(st->first, 0), 0, &st->diff1), LY_EINVAL);
 
-    assert_int_equal(lyd_diff(NULL, NULL, 0, NULL), LY_EINVAL);
+    assert_int_equal(lyd_diff_siblings(NULL, NULL, 0, NULL), LY_EINVAL);
 }
 
 static void
@@ -288,10 +288,10 @@
     assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, xml, LYD_XML, LYD_PARSE_ONLY, 0, &st->second));
     assert_non_null(st->second);
 
-    assert_int_equal(lyd_diff(st->first, st->second, 0, &st->diff1), LY_SUCCESS);
+    assert_int_equal(lyd_diff_siblings(st->first, st->second, 0, &st->diff1), LY_SUCCESS);
     assert_null(st->diff1);
 
-    assert_int_equal(lyd_diff_apply(&st->first, st->diff1), LY_SUCCESS);
+    assert_int_equal(lyd_diff_apply_all(&st->first, st->diff1), LY_SUCCESS);
     lyd_print_mem(&st->xml1, st->first, LYD_XML, LYD_PRINT_WITHSIBLINGS);
     lyd_print_mem(&st->xml2, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS);
     assert_string_equal(st->xml1, st->xml2);
@@ -313,7 +313,7 @@
     assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, xml, LYD_XML, LYD_PARSE_ONLY, 0, &st->second));
     assert_non_null(st->second);
 
-    assert_int_equal(lyd_diff(st->first, st->second, 0, &st->diff1), LY_SUCCESS);
+    assert_int_equal(lyd_diff_siblings(st->first, st->second, 0, &st->diff1), LY_SUCCESS);
 
     assert_non_null(st->diff1);
     lyd_print_mem(&st->xml, st->diff1, LYD_XML, LYD_PRINT_WITHSIBLINGS);
@@ -326,7 +326,7 @@
         "</hidden>"
     );
 
-    assert_int_equal(lyd_diff_apply(&st->first, st->diff1), LY_SUCCESS);
+    assert_int_equal(lyd_diff_apply_all(&st->first, st->diff1), LY_SUCCESS);
     lyd_print_mem(&st->xml1, st->first, LYD_XML, LYD_PRINT_WITHSIBLINGS);
     lyd_print_mem(&st->xml2, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS);
     assert_string_equal(st->xml1, st->xml2);
@@ -345,7 +345,7 @@
     assert_non_null(st->first);
     st->second = NULL;
 
-    assert_int_equal(lyd_diff(st->first, st->second, 0, &st->diff1), LY_SUCCESS);
+    assert_int_equal(lyd_diff_siblings(st->first, st->second, 0, &st->diff1), LY_SUCCESS);
 
     assert_non_null(st->diff1);
     lyd_print_mem(&st->xml, st->diff1, LYD_XML, LYD_PRINT_WITHSIBLINGS);
@@ -358,7 +358,7 @@
         "</hidden>"
     );
 
-    assert_int_equal(lyd_diff_apply(&st->first, st->diff1), LY_SUCCESS);
+    assert_int_equal(lyd_diff_apply_all(&st->first, st->diff1), LY_SUCCESS);
     assert_ptr_equal(st->first, st->second);
 }
 
@@ -372,10 +372,10 @@
     assert_non_null(st->first);
     st->second = NULL;
 
-    assert_int_equal(lyd_diff(NULL, NULL, 0, &st->diff1), LY_SUCCESS);
+    assert_int_equal(lyd_diff_siblings(NULL, NULL, 0, &st->diff1), LY_SUCCESS);
     assert_null(st->diff1);
 
-    assert_int_equal(lyd_diff(NULL, lyd_node_children(st->first, 0), 0, &st->diff1), LY_SUCCESS);
+    assert_int_equal(lyd_diff_siblings(NULL, lyd_node_children(st->first, 0), 0, &st->diff1), LY_SUCCESS);
 
     assert_non_null(st->diff1);
     lyd_print_mem(&st->xml, st->diff1, LYD_XML, LYD_PRINT_WITHSIBLINGS);
@@ -386,7 +386,7 @@
     );
 
     free(st->xml);
-    assert_int_equal(lyd_diff(lyd_node_children(st->first, 0), NULL, 0, &st->diff2), LY_SUCCESS);
+    assert_int_equal(lyd_diff_siblings(lyd_node_children(st->first, 0), NULL, 0, &st->diff2), LY_SUCCESS);
 
     assert_non_null(st->diff2);
     lyd_print_mem(&st->xml, st->diff2, LYD_XML, LYD_PRINT_WITHSIBLINGS);
@@ -428,7 +428,7 @@
     assert_non_null(st->third);
 
     /* diff1 */
-    assert_int_equal(lyd_diff(st->first, st->second, 0, &st->diff1), LY_SUCCESS);
+    assert_int_equal(lyd_diff_siblings(st->first, st->second, 0, &st->diff1), LY_SUCCESS);
 
     assert_non_null(st->diff1);
     lyd_print_mem(&st->xml, st->diff1, LYD_XML, LYD_PRINT_WITHSIBLINGS);
@@ -443,13 +443,13 @@
         "</hidden>"
     );
 
-    assert_int_equal(lyd_diff_apply(&st->first, st->diff1), LY_SUCCESS);
+    assert_int_equal(lyd_diff_apply_all(&st->first, st->diff1), LY_SUCCESS);
     lyd_print_mem(&st->xml1, st->first, LYD_XML, LYD_PRINT_WITHSIBLINGS);
     lyd_print_mem(&st->xml2, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS);
     assert_string_equal(st->xml1, st->xml2);
 
     /* diff2 */
-    assert_int_equal(lyd_diff(st->second, st->third, 0, &st->diff2), LY_SUCCESS);
+    assert_int_equal(lyd_diff_siblings(st->second, st->third, 0, &st->diff2), LY_SUCCESS);
 
     assert_non_null(st->diff2);
     free(st->xml);
@@ -464,7 +464,7 @@
         "</hidden>"
     );
 
-    assert_int_equal(lyd_diff_apply(&st->second, st->diff2), LY_SUCCESS);
+    assert_int_equal(lyd_diff_apply_all(&st->second, st->diff2), LY_SUCCESS);
     free(st->xml1);
     lyd_print_mem(&st->xml1, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS);
     free(st->xml2);
@@ -472,7 +472,7 @@
     assert_string_equal(st->xml1, st->xml2);
 
     /* merge */
-    assert_int_equal(lyd_diff_merge(st->diff2, &st->diff1), LY_SUCCESS);
+    assert_int_equal(lyd_diff_merge_all(st->diff2, &st->diff1), LY_SUCCESS);
 
     free(st->xml);
     lyd_print_mem(&st->xml, st->diff1, LYD_XML, LYD_PRINT_WITHSIBLINGS);
@@ -512,7 +512,7 @@
     assert_non_null(st->third);
 
     /* diff1 */
-    assert_int_equal(lyd_diff(st->first, st->second, 0, &st->diff1), LY_SUCCESS);
+    assert_int_equal(lyd_diff_siblings(st->first, st->second, 0, &st->diff1), LY_SUCCESS);
 
     assert_non_null(st->diff1);
     lyd_print_mem(&st->xml, st->diff1, LYD_XML, LYD_PRINT_WITHSIBLINGS);
@@ -533,13 +533,13 @@
         "</df>"
     );
 
-    assert_int_equal(lyd_diff_apply(&st->first, st->diff1), LY_SUCCESS);
+    assert_int_equal(lyd_diff_apply_all(&st->first, st->diff1), LY_SUCCESS);
     lyd_print_mem(&st->xml1, st->first, LYD_XML, LYD_PRINT_WITHSIBLINGS);
     lyd_print_mem(&st->xml2, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS);
     assert_string_equal(st->xml1, st->xml2);
 
     /* diff2 */
-    assert_int_equal(lyd_diff(st->second, st->third, 0, &st->diff2), LY_SUCCESS);
+    assert_int_equal(lyd_diff_siblings(st->second, st->third, 0, &st->diff2), LY_SUCCESS);
 
     assert_non_null(st->diff2);
     free(st->xml);
@@ -557,7 +557,7 @@
         "</df>"
     );
 
-    assert_int_equal(lyd_diff_apply(&st->second, st->diff2), LY_SUCCESS);
+    assert_int_equal(lyd_diff_apply_all(&st->second, st->diff2), LY_SUCCESS);
     free(st->xml1);
     lyd_print_mem(&st->xml1, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS);
     free(st->xml2);
@@ -565,7 +565,7 @@
     /* TODO ordering assert_string_equal(st->xml1, st->xml2); */
 
     /* merge */
-    assert_int_equal(lyd_diff_merge(st->diff2, &st->diff1), LY_SUCCESS);
+    assert_int_equal(lyd_diff_merge_all(st->diff2, &st->diff1), LY_SUCCESS);
 
     free(st->xml);
     lyd_print_mem(&st->xml, st->diff1, LYD_XML, LYD_PRINT_WITHSIBLINGS);
@@ -616,7 +616,7 @@
     assert_non_null(st->third);
 
     /* diff1 */
-    assert_int_equal(lyd_diff(st->first, st->second, 0, &st->diff1), LY_SUCCESS);
+    assert_int_equal(lyd_diff_siblings(st->first, st->second, 0, &st->diff1), LY_SUCCESS);
 
     assert_non_null(st->diff1);
     lyd_print_mem(&st->xml, st->diff1, LYD_XML, LYD_PRINT_WITHSIBLINGS);
@@ -627,13 +627,13 @@
         "</df>"
     );
 
-    assert_int_equal(lyd_diff_apply(&st->first, st->diff1), LY_SUCCESS);
+    assert_int_equal(lyd_diff_apply_all(&st->first, st->diff1), LY_SUCCESS);
     lyd_print_mem(&st->xml1, st->first, LYD_XML, LYD_PRINT_WITHSIBLINGS);
     lyd_print_mem(&st->xml2, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS);
     assert_string_equal(st->xml1, st->xml2);
 
     /* diff2 */
-    assert_int_equal(lyd_diff(st->second, st->third, 0, &st->diff2), LY_SUCCESS);
+    assert_int_equal(lyd_diff_siblings(st->second, st->third, 0, &st->diff2), LY_SUCCESS);
 
     assert_non_null(st->diff2);
     free(st->xml);
@@ -645,7 +645,7 @@
         "</df>"
     );
 
-    assert_int_equal(lyd_diff_apply(&st->second, st->diff2), LY_SUCCESS);
+    assert_int_equal(lyd_diff_apply_all(&st->second, st->diff2), LY_SUCCESS);
     free(st->xml1);
     lyd_print_mem(&st->xml1, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS);
     free(st->xml2);
@@ -653,7 +653,7 @@
     assert_string_equal(st->xml1, st->xml2);
 
     /* merge */
-    assert_int_equal(lyd_diff_merge(st->diff2, &st->diff1), LY_SUCCESS);
+    assert_int_equal(lyd_diff_merge_all(st->diff2, &st->diff1), LY_SUCCESS);
 
     free(st->xml);
     lyd_print_mem(&st->xml, st->diff1, LYD_XML, LYD_PRINT_WITHSIBLINGS);
@@ -700,7 +700,7 @@
     assert_non_null(st->third);
 
     /* diff1 */
-    assert_int_equal(lyd_diff(st->first, st->second, 0, &st->diff1), LY_SUCCESS);
+    assert_int_equal(lyd_diff_siblings(st->first, st->second, 0, &st->diff1), LY_SUCCESS);
 
     assert_non_null(st->diff1);
     lyd_print_mem(&st->xml, st->diff1, LYD_XML, LYD_PRINT_WITHSIBLINGS);
@@ -710,13 +710,13 @@
         "</df>"
     );
 
-    assert_int_equal(lyd_diff_apply(&st->first, st->diff1), LY_SUCCESS);
+    assert_int_equal(lyd_diff_apply_all(&st->first, st->diff1), LY_SUCCESS);
     lyd_print_mem(&st->xml1, st->first, LYD_XML, LYD_PRINT_WITHSIBLINGS);
     lyd_print_mem(&st->xml2, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS);
     assert_string_equal(st->xml1, st->xml2);
 
     /* diff2 */
-    assert_int_equal(lyd_diff(st->second, st->third, 0, &st->diff2), LY_SUCCESS);
+    assert_int_equal(lyd_diff_siblings(st->second, st->third, 0, &st->diff2), LY_SUCCESS);
 
     assert_non_null(st->diff2);
     free(st->xml);
@@ -728,7 +728,7 @@
         "</df>"
     );
 
-    assert_int_equal(lyd_diff_apply(&st->second, st->diff2), LY_SUCCESS);
+    assert_int_equal(lyd_diff_apply_all(&st->second, st->diff2), LY_SUCCESS);
     free(st->xml1);
     lyd_print_mem(&st->xml1, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS);
     free(st->xml2);
@@ -736,7 +736,7 @@
     assert_string_equal(st->xml1, st->xml2);
 
     /* merge */
-    assert_int_equal(lyd_diff_merge(st->diff2, &st->diff1), LY_SUCCESS);
+    assert_int_equal(lyd_diff_merge_all(st->diff2, &st->diff1), LY_SUCCESS);
 
     free(st->xml);
     lyd_print_mem(&st->xml, st->diff1, LYD_XML, LYD_PRINT_WITHSIBLINGS);
@@ -775,7 +775,7 @@
     assert_non_null(st->third);
 
     /* diff1 */
-    assert_int_equal(lyd_diff(st->first, st->second, 0, &st->diff1), LY_SUCCESS);
+    assert_int_equal(lyd_diff_siblings(st->first, st->second, 0, &st->diff1), LY_SUCCESS);
 
     assert_non_null(st->diff1);
     lyd_print_mem(&st->xml, st->diff1, LYD_XML, LYD_PRINT_WITHSIBLINGS);
@@ -786,13 +786,13 @@
         "</df>"
     );
 
-    assert_int_equal(lyd_diff_apply(&st->first, st->diff1), LY_SUCCESS);
+    assert_int_equal(lyd_diff_apply_all(&st->first, st->diff1), LY_SUCCESS);
     lyd_print_mem(&st->xml1, st->first, LYD_XML, LYD_PRINT_WITHSIBLINGS);
     lyd_print_mem(&st->xml2, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS);
     assert_string_equal(st->xml1, st->xml2);
 
     /* diff2 */
-    assert_int_equal(lyd_diff(st->second, st->third, 0, &st->diff2), LY_SUCCESS);
+    assert_int_equal(lyd_diff_siblings(st->second, st->third, 0, &st->diff2), LY_SUCCESS);
 
     assert_non_null(st->diff2);
     free(st->xml);
@@ -804,7 +804,7 @@
         "</df>"
     );
 
-    assert_int_equal(lyd_diff_apply(&st->second, st->diff2), LY_SUCCESS);
+    assert_int_equal(lyd_diff_apply_all(&st->second, st->diff2), LY_SUCCESS);
     free(st->xml1);
     lyd_print_mem(&st->xml1, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS);
     free(st->xml2);
@@ -812,7 +812,7 @@
     assert_string_equal(st->xml1, st->xml2);
 
     /* merge */
-    assert_int_equal(lyd_diff_merge(st->diff2, &st->diff1), LY_SUCCESS);
+    assert_int_equal(lyd_diff_merge_all(st->diff2, &st->diff1), LY_SUCCESS);
 
     free(st->xml);
     lyd_print_mem(&st->xml, st->diff1, LYD_XML, LYD_PRINT_WITHSIBLINGS);
@@ -850,7 +850,7 @@
     assert_non_null(st->third);
 
     /* diff1 */
-    assert_int_equal(lyd_diff(st->first, st->second, LYD_DIFF_WITHDEFAULTS, &st->diff1), LY_SUCCESS);
+    assert_int_equal(lyd_diff_siblings(st->first, st->second, LYD_DIFF_DEFAULTS, &st->diff1), LY_SUCCESS);
 
     assert_non_null(st->diff1);
     lyd_print_mem(&st->xml, st->diff1, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_ALL);
@@ -864,14 +864,14 @@
         "</df>"
     );
 
-    assert_int_equal(lyd_diff_apply(&st->first, st->diff1), LY_SUCCESS);
+    assert_int_equal(lyd_diff_apply_all(&st->first, st->diff1), LY_SUCCESS);
     lyd_print_mem(&st->xml1, st->first, LYD_XML, LYD_PRINT_WITHSIBLINGS);
     lyd_print_mem(&st->xml2, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS);
     /* TODO just an ordering problem
     assert_string_equal(st->xml1, st->xml2);*/
 
     /* diff2 */
-    assert_int_equal(lyd_diff(st->second, st->third, LYD_DIFF_WITHDEFAULTS, &st->diff2), LY_SUCCESS);
+    assert_int_equal(lyd_diff_siblings(st->second, st->third, LYD_DIFF_DEFAULTS, &st->diff2), LY_SUCCESS);
 
     assert_non_null(st->diff2);
     free(st->xml);
@@ -883,7 +883,7 @@
         "</df>"
     );
 
-    assert_int_equal(lyd_diff_apply(&st->second, st->diff2), LY_SUCCESS);
+    assert_int_equal(lyd_diff_apply_all(&st->second, st->diff2), LY_SUCCESS);
     free(st->xml1);
     lyd_print_mem(&st->xml1, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS);
     free(st->xml2);
@@ -891,7 +891,7 @@
     /* TODO ordering assert_string_equal(st->xml1, st->xml2); */
 
     /* merge */
-    assert_int_equal(lyd_diff_merge(st->diff2, &st->diff1), LY_SUCCESS);
+    assert_int_equal(lyd_diff_merge_all(st->diff2, &st->diff1), LY_SUCCESS);
 
     free(st->xml);
     lyd_print_mem(&st->xml, st->diff1, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_ALL);
diff --git a/tests/utests/data/test_lyb.c b/tests/utests/data/test_lyb.c
index a46f3d6..ee29809 100644
--- a/tests/utests/data/test_lyb.c
+++ b/tests/utests/data/test_lyb.c
@@ -304,7 +304,7 @@
         "<leaf3 xmlns:or=\"urn:ietf:params:xml:ns:yang:ietf-origin\" or:origin=\"or:system\">125</leaf3>"
     "</cont>";
 
-    assert_non_null(lys_parse_mem(st->ctx, origin_yang, LYS_IN_YANG));
+    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"));
 
     assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, data_xml, LYD_XML, LYD_PARSE_ONLY, 0, &st->dt1));
@@ -514,8 +514,8 @@
         "<iref>random-identity</iref>"
     "</random>";
 
-    assert_non_null(lys_parse_mem(st->ctx, links_yang, LYS_IN_YANG));
-    assert_non_null(lys_parse_mem(st->ctx, statements_yang, LYS_IN_YANG));
+    assert_int_equal(LY_SUCCESS, lys_parse_mem(st->ctx, links_yang, LYS_IN_YANG, NULL));
+    assert_int_equal(LY_SUCCESS, lys_parse_mem(st->ctx, statements_yang, LYS_IN_YANG, 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_merge.c b/tests/utests/data/test_merge.c
index 4ad6c9f..2ded52e 100644
--- a/tests/utests/data/test_merge.c
+++ b/tests/utests/data/test_merge.c
@@ -242,7 +242,7 @@
         assert_int_equal(LY_SUCCESS, lyd_parse_data(st->ctx, in, LYD_XML, LYD_PARSE_ONLY, 0, &st->source));
         assert_non_null(st->source);
 
-        assert_int_equal(LY_SUCCESS, lyd_merge(&st->target, st->source, LYD_MERGE_DESTRUCT));
+        assert_int_equal(LY_SUCCESS, lyd_merge_siblings(&st->target, st->source, LYD_MERGE_DESTRUCT));
         st->source = NULL;
     }
 
@@ -272,7 +272,7 @@
     const char *result = "<A xmlns=\"urn:x\"><f1>aa</f1><B><f2>bb</f2></B></A>";
     char *printed = NULL;
 
-    assert_non_null(lys_parse_mem(st->ctx, sch, LYS_IN_YANG));
+    assert_int_equal(LY_SUCCESS, lys_parse_mem(st->ctx, sch, LYS_IN_YANG, NULL));
 
     assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, src, LYD_XML, 0, LYD_VALIDATE_PRESENT, &st->source));
     assert_non_null(st->source);
@@ -281,8 +281,8 @@
     assert_non_null(st->target);
 
     /* merge them */
-    assert_int_equal(lyd_merge(&st->target, st->source, 0), LY_SUCCESS);
-    assert_int_equal(lyd_validate(&st->target, NULL, LYD_VALIDATE_PRESENT, NULL), LY_SUCCESS);
+    assert_int_equal(lyd_merge_siblings(&st->target, st->source, 0), LY_SUCCESS);
+    assert_int_equal(lyd_validate_all(&st->target, NULL, LYD_VALIDATE_PRESENT, NULL), LY_SUCCESS);
 
     /* check the result */
     lyd_print_mem(&printed, st->target, LYD_XML, LYD_PRINT_WITHSIBLINGS);
@@ -314,7 +314,7 @@
     const char *result = "<A xmlns=\"aa:A\"><B><f2>aaa</f2></B><C><f3>bbb</f3></C></A>";
     char *printed = NULL;
 
-    assert_non_null(lys_parse_mem(st->ctx, sch, LYS_IN_YANG));
+    assert_int_equal(LY_SUCCESS, lys_parse_mem(st->ctx, sch, LYS_IN_YANG, NULL));
 
     assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, src, LYD_XML, 0, LYD_VALIDATE_PRESENT, &st->source));
     assert_non_null(st->source);
@@ -323,8 +323,8 @@
     assert_non_null(st->target);
 
     /* merge them */
-    assert_int_equal(lyd_merge(&st->target, st->source, 0), LY_SUCCESS);
-    assert_int_equal(lyd_validate(&st->target, NULL, LYD_VALIDATE_PRESENT, NULL), LY_SUCCESS);
+    assert_int_equal(lyd_merge_siblings(&st->target, st->source, 0), LY_SUCCESS);
+    assert_int_equal(lyd_validate_all(&st->target, NULL, LYD_VALIDATE_PRESENT, NULL), LY_SUCCESS);
 
     /* check the result */
     lyd_print_mem(&printed, st->target, LYD_XML, LYD_PRINT_WITHSIBLINGS);
@@ -384,7 +384,7 @@
     "</inner1>";
     char *printed = NULL;
 
-    assert_non_null(lys_parse_mem(st->ctx, sch, LYS_IN_YANG));
+    assert_int_equal(LY_SUCCESS, lys_parse_mem(st->ctx, sch, LYS_IN_YANG, NULL));
 
     assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, src, LYD_XML, 0, LYD_VALIDATE_PRESENT, &st->source));
     assert_non_null(st->source);
@@ -393,8 +393,8 @@
     assert_non_null(st->target);
 
     /* merge them */
-    assert_int_equal(lyd_merge(&st->target, st->source, LYD_MERGE_EXPLICIT), LY_SUCCESS);
-    assert_int_equal(lyd_validate(&st->target, NULL, LYD_VALIDATE_PRESENT, NULL), LY_SUCCESS);
+    assert_int_equal(lyd_merge_siblings(&st->target, st->source, 0), LY_SUCCESS);
+    assert_int_equal(lyd_validate_all(&st->target, NULL, LYD_VALIDATE_PRESENT, NULL), LY_SUCCESS);
 
     /* check the result */
     lyd_print_mem(&printed, st->target, LYD_XML, LYD_PRINT_WITHSIBLINGS);
@@ -463,7 +463,7 @@
     "</inner1>";
     char *printed = NULL;
 
-    assert_non_null(lys_parse_mem(st->ctx, sch, LYS_IN_YANG));
+    assert_int_equal(LY_SUCCESS, lys_parse_mem(st->ctx, sch, LYS_IN_YANG, NULL));
 
     assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, src, LYD_XML, 0, LYD_VALIDATE_PRESENT, &st->source));
     assert_non_null(st->source);
@@ -472,8 +472,8 @@
     assert_non_null(st->target);
 
     /* merge them */
-    assert_int_equal(lyd_merge(&st->target, st->source, LYD_MERGE_EXPLICIT), LY_SUCCESS);
-    assert_int_equal(lyd_validate(&st->target, NULL, LYD_VALIDATE_PRESENT, NULL), LY_SUCCESS);
+    assert_int_equal(lyd_merge_siblings(&st->target, st->source, 0), LY_SUCCESS);
+    assert_int_equal(lyd_validate_all(&st->target, NULL, LYD_VALIDATE_PRESENT, NULL), LY_SUCCESS);
 
     /* check the result */
     lyd_print_mem(&printed, st->target, LYD_XML, LYD_PRINT_WITHSIBLINGS);
@@ -521,7 +521,7 @@
     "</cont>";
     char *printed = NULL;
 
-    assert_non_null(lys_parse_mem(st->ctx, sch, LYS_IN_YANG));
+    assert_int_equal(LY_SUCCESS, lys_parse_mem(st->ctx, sch, LYS_IN_YANG, NULL));
 
     assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, src, LYD_XML, 0, LYD_VALIDATE_PRESENT, &st->source));
     assert_non_null(st->source);
@@ -530,8 +530,8 @@
     assert_non_null(st->target);
 
     /* merge them */
-    assert_int_equal(lyd_merge(&st->target, st->source, 0), LY_SUCCESS);
-    assert_int_equal(lyd_validate(&st->target, NULL, LYD_VALIDATE_PRESENT, NULL), LY_SUCCESS);
+    assert_int_equal(lyd_merge_siblings(&st->target, st->source, 0), LY_SUCCESS);
+    assert_int_equal(lyd_validate_all(&st->target, NULL, LYD_VALIDATE_PRESENT, NULL), LY_SUCCESS);
 
     /* check the result */
     lyd_print_mem(&printed, st->target, LYD_XML, LYD_PRINT_WITHSIBLINGS);
@@ -543,7 +543,6 @@
 test_dflt(void **state)
 {
     struct state *st = (*state);
-    struct lyd_node *tmp;
     const char *sch =
     "module merge-dflt {"
         "namespace \"urn:merge-dflt\";"
@@ -562,19 +561,16 @@
         "}"
     "}";
 
-    assert_non_null(lys_parse_mem(st->ctx, sch, LYS_IN_YANG));
+    assert_int_equal(LY_SUCCESS, lys_parse_mem(st->ctx, sch, LYS_IN_YANG, NULL));
 
-    st->target = lyd_new_path(NULL, st->ctx, "/merge-dflt:top/c", "c_dflt", 0);
-    assert_non_null(st->target);
-    assert_int_equal(lyd_validate(&(st->target), NULL, LYD_VALIDATE_PRESENT, NULL), LY_SUCCESS);
+    assert_int_equal(lyd_new_path(NULL, st->ctx, "/merge-dflt:top/c", "c_dflt", 0, &st->target), LY_SUCCESS);
+    assert_int_equal(lyd_validate_all(&(st->target), NULL, LYD_VALIDATE_PRESENT, NULL), LY_SUCCESS);
 
-    st->source = lyd_new_path(NULL, st->ctx, "/merge-dflt:top/a", "a_val", 0);
-    assert_non_null(st->source);
-    tmp = lyd_new_path(st->source, st->ctx, "/merge-dflt:top/b", "b_val", 0);
-    assert_non_null(tmp);
-    assert_int_equal(lyd_validate(&(st->source), NULL, LYD_VALIDATE_PRESENT, NULL), LY_SUCCESS);
+    assert_int_equal(lyd_new_path(NULL, st->ctx, "/merge-dflt:top/a", "a_val", 0, &st->source), LY_SUCCESS);
+    assert_int_equal(lyd_new_path(st->source, st->ctx, "/merge-dflt:top/b", "b_val", 0, NULL), LY_SUCCESS);
+    assert_int_equal(lyd_validate_all(&(st->source), NULL, LYD_VALIDATE_PRESENT, NULL), LY_SUCCESS);
 
-    assert_int_equal(lyd_merge(&st->target, st->source, LYD_MERGE_DESTRUCT), LY_SUCCESS);
+    assert_int_equal(lyd_merge_siblings(&st->target, st->source, LYD_MERGE_DESTRUCT | LYD_MERGE_DEFAULTS), LY_SUCCESS);
     st->source = NULL;
 
     /* c should be replaced and now be default */
@@ -585,7 +581,6 @@
 test_dflt2(void **state)
 {
     struct state *st = (*state);
-    struct lyd_node *tmp;
     const char *sch =
     "module merge-dflt {"
         "namespace \"urn:merge-dflt\";"
@@ -604,19 +599,16 @@
         "}"
     "}";
 
-    assert_non_null(lys_parse_mem(st->ctx, sch, LYS_IN_YANG));
+    assert_int_equal(LY_SUCCESS, lys_parse_mem(st->ctx, sch, LYS_IN_YANG, NULL));
 
-    st->target = lyd_new_path(NULL, st->ctx, "/merge-dflt:top/c", "c_dflt", 0);
-    assert_non_null(st->target);
-    assert_int_equal(lyd_validate(&(st->target), NULL, LYD_VALIDATE_PRESENT, NULL), LY_SUCCESS);
+    assert_int_equal(lyd_new_path(NULL, st->ctx, "/merge-dflt:top/c", "c_dflt", 0, &st->target), LY_SUCCESS);
+    assert_int_equal(lyd_validate_all(&(st->target), NULL, LYD_VALIDATE_PRESENT, NULL), LY_SUCCESS);
 
-    st->source = lyd_new_path(NULL, st->ctx, "/merge-dflt:top/a", "a_val", 0);
-    assert_non_null(st->source);
-    tmp = lyd_new_path(st->source, st->ctx, "/merge-dflt:top/b", "b_val", 0);
-    assert_non_null(tmp);
-    assert_int_equal(lyd_validate(&(st->source), NULL, LYD_VALIDATE_PRESENT, NULL), LY_SUCCESS);
+    assert_int_equal(lyd_new_path(NULL, st->ctx, "/merge-dflt:top/a", "a_val", 0, &st->source), LY_SUCCESS);
+    assert_int_equal(lyd_new_path(st->source, st->ctx, "/merge-dflt:top/b", "b_val", 0, NULL), LY_SUCCESS);
+    assert_int_equal(lyd_validate_all(&(st->source), NULL, LYD_VALIDATE_PRESENT, NULL), LY_SUCCESS);
 
-    assert_int_equal(lyd_merge(&st->target, st->source, LYD_MERGE_EXPLICIT), LY_SUCCESS);
+    assert_int_equal(lyd_merge_siblings(&st->target, st->source, 0), LY_SUCCESS);
 
     /* c should not be replaced, so c remains not default */
     assert_false(lyd_node_children(st->target, 0)->flags & LYD_DEFAULT);
@@ -643,7 +635,7 @@
                       "<l xmlns=\"urn:x\"><n>c</n><r>a</r></l>";
     char *prt = NULL;
 
-    assert_non_null(lys_parse_mem(st->ctx, sch, LYS_IN_YANG));
+    assert_int_equal(LY_SUCCESS, lys_parse_mem(st->ctx, sch, LYS_IN_YANG, NULL));
 
     assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, src, LYD_XML, 0, LYD_VALIDATE_PRESENT, &st->source));
     assert_non_null(st->source);
@@ -651,8 +643,7 @@
     assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, trg, LYD_XML, 0, LYD_VALIDATE_PRESENT, &st->target));
     assert_non_null(st->target);
 
-    assert_int_equal(lyd_merge(&st->target, st->source, LYD_MERGE_DESTRUCT), LY_SUCCESS);
-    st->source = NULL;
+    assert_int_equal(lyd_merge_siblings(&st->target, st->source, 0), LY_SUCCESS);
 
     lyd_print_mem(&prt, st->target, LYD_XML, LYD_PRINT_WITHSIBLINGS);
     assert_string_equal(prt, res);
diff --git a/tests/utests/data/test_new.c b/tests/utests/data/test_new.c
index ee42a0b..c9c32f8 100644
--- a/tests/utests/data/test_new.c
+++ b/tests/utests/data/test_new.c
@@ -65,7 +65,7 @@
 #endif
 
     assert_int_equal(LY_SUCCESS, ly_ctx_new(NULL, 0, &ctx));
-    assert_non_null(lys_parse_mem(ctx, schema_a, LYS_IN_YANG));
+    assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, schema_a, LYS_IN_YANG, NULL));
 
     return 0;
 }
@@ -112,93 +112,72 @@
     assert_non_null(mod);
 
     /* list */
-    node = lyd_new_list(NULL, mod, "l1", "val_a", "val_b");
-    assert_non_null(node);
+    assert_int_equal(lyd_new_list(NULL, mod, "l1", &node, "val_a", "val_b"), LY_SUCCESS);
     lyd_free_tree(node);
 
-    node = lyd_new_list2(NULL, mod, "l1", "[]");
-    assert_null(node);
+    assert_int_equal(lyd_new_list2(NULL, mod, "l1", "[]", &node), LY_EVALID);
     logbuf_assert("Unexpected XPath token ] (]).");
 
-    node = lyd_new_list2(NULL, mod, "l1", "[key1='a'][key2='b']");
-    assert_null(node);
+    assert_int_equal(lyd_new_list2(NULL, mod, "l1", "[key1='a'][key2='b']", NULL), LY_ENOTFOUND);
     logbuf_assert("Not found node \"key1\" in path.");
 
-    node = lyd_new_list2(NULL, mod, "l1", "[a='a'][b='b'][c='c']");
-    assert_null(node);
+    assert_int_equal(lyd_new_list2(NULL, mod, "l1", "[a='a'][b='b'][c='c']", NULL), LY_EVALID);
     logbuf_assert("Key expected instead of leaf \"c\" in path. /a:l1/c");
 
-    node = lyd_new_list2(NULL, mod, "c", "[a='a'][b='b']");
-    assert_null(node);
+    assert_int_equal(lyd_new_list2(NULL, mod, "c", "[a='a'][b='b']", NULL), LY_ENOTFOUND);
     logbuf_assert("List node \"c\" not found.");
 
-    node = lyd_new_list2(NULL, mod, "l1", "[a='a'][b='b']");
-    assert_non_null(node);
+    assert_int_equal(lyd_new_list2(NULL, mod, "l1", "[a='a'][b='b']", &node), LY_SUCCESS);
     lyd_free_tree(node);
 
-    node = lyd_new_list2(NULL, mod, "l1", "[a=''][b='']");
-    assert_non_null(node);
+    assert_int_equal(lyd_new_list2(NULL, mod, "l1", "[a=''][b='']", &node), LY_SUCCESS);
     lyd_free_tree(node);
 
-    node = lyd_new_list2(NULL, mod, "l1", "[a:a='a'][a:b='b']");
-    assert_non_null(node);
+    assert_int_equal(lyd_new_list2(NULL, mod, "l1", "[a:a='a'][a:b='b']", &node), LY_SUCCESS);
     lyd_free_tree(node);
 
-    node = lyd_new_list2(NULL, mod, "l1", "[a=   'a']\n[b  =\t'b']");
-    assert_non_null(node);
+    assert_int_equal(lyd_new_list2(NULL, mod, "l1", "[a=   'a']\n[b  =\t'b']", &node), LY_SUCCESS);
     lyd_free_tree(node);
 
     /* leaf */
-    node = lyd_new_term(NULL, mod, "foo", "[a='a'][b='b'][c='c']");
-    assert_null(node);
+    assert_int_equal(lyd_new_term(NULL, mod, "foo", "[a='a'][b='b'][c='c']", NULL), LY_EVALID);
     logbuf_assert("Invalid uint16 value \"[a='a'][b='b'][c='c']\". /a:foo");
 
-    node = lyd_new_term(NULL, mod, "c", "value");
-    assert_null(node);
+    assert_int_equal(lyd_new_term(NULL, mod, "c", "value", NULL), LY_ENOTFOUND);
     logbuf_assert("Term node \"c\" not found.");
 
-    node = lyd_new_term(NULL, mod, "foo", "256");
-    assert_non_null(node);
+    assert_int_equal(lyd_new_term(NULL, mod, "foo", "256", &node), LY_SUCCESS);
     lyd_free_tree(node);
 
     /* leaf-list */
-    node = lyd_new_term(NULL, mod, "ll", "ahoy");
-    assert_non_null(node);
+    assert_int_equal(lyd_new_term(NULL, mod, "ll", "ahoy", &node), LY_SUCCESS);
     lyd_free_tree(node);
 
     /* container */
-    node = lyd_new_inner(NULL, mod, "c");
-    assert_non_null(node);
+    assert_int_equal(lyd_new_inner(NULL, mod, "c", &node), LY_SUCCESS);
     lyd_free_tree(node);
 
-    node = lyd_new_inner(NULL, mod, "l1");
-    assert_null(node);
+    assert_int_equal(lyd_new_inner(NULL, mod, "l1", NULL), LY_ENOTFOUND);
     logbuf_assert("Inner node (and not a list) \"l1\" not found.");
 
-    node = lyd_new_inner(NULL, mod, "l2");
-    assert_null(node);
+    assert_int_equal(lyd_new_inner(NULL, mod, "l2", NULL), LY_ENOTFOUND);
     logbuf_assert("Inner node (and not a list) \"l2\" not found.");
 
     /* anydata */
-    node = lyd_new_any(NULL, mod, "any", "some-value", LYD_ANYDATA_STRING);
-    assert_non_null(node);
+    assert_int_equal(lyd_new_any(NULL, mod, "any", "some-value", LYD_ANYDATA_STRING, &node), LY_SUCCESS);
     lyd_free_tree(node);
 
     /* key-less list */
-    node = lyd_new_list2(NULL, mod, "l2", "[a='a'][b='b']");
-    assert_null(node);
+    assert_int_equal(lyd_new_list2(NULL, mod, "l2", "[a='a'][b='b']", NULL), LY_EVALID);
     logbuf_assert("List predicate defined for keyless list \"l2\" in path.");
 
-    node = lyd_new_list2(NULL, mod, "l2", "");
-    assert_non_null(node);
+    assert_int_equal(lyd_new_list2(NULL, mod, "l2", "", &node), LY_SUCCESS);
     lyd_free_tree(node);
 
-    node = lyd_new_list2(NULL, mod, "l2", NULL);
-    assert_non_null(node);
+    assert_int_equal(lyd_new_list2(NULL, mod, "l2", NULL, &node), LY_SUCCESS);
     lyd_free_tree(node);
 
-    node = lyd_new_list(NULL, mod, "l2");
-    assert_non_null(node);
+    assert_int_equal(lyd_new_list(NULL, mod, "l2", &node), LY_SUCCESS);
     lyd_free_tree(node);
 
     *state = NULL;
@@ -212,16 +191,14 @@
     struct lyd_node *root, *node;
     struct lyd_node_opaq *opq;
 
-    root = lyd_new_opaq(NULL, ctx, "node1", NULL, "my-module");
-    assert_non_null(root);
+    assert_int_equal(lyd_new_opaq(NULL, ctx, "node1", NULL, "my-module", &root), LY_SUCCESS);
     assert_null(root->schema);
     opq = (struct lyd_node_opaq *)root;
     assert_string_equal(opq->name, "node1");
     assert_string_equal(opq->value, "");
     assert_string_equal(opq->prefix.ns, "my-module");
 
-    node = lyd_new_opaq(root, NULL, "node2", "value", "my-module2");
-    assert_non_null(node);
+    assert_int_equal(lyd_new_opaq(root, NULL, "node2", "value", "my-module2", &node), LY_SUCCESS);
     assert_null(node->schema);
     opq = (struct lyd_node_opaq *)node;
     assert_string_equal(opq->name, "node2");
diff --git a/tests/utests/data/test_parser_xml.c b/tests/utests/data/test_parser_xml.c
index 79c85f5..06510da 100644
--- a/tests/utests/data/test_parser_xml.c
+++ b/tests/utests/data/test_parser_xml.c
@@ -84,7 +84,7 @@
     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(lys_parse_mem(ctx, schema_a, LYS_IN_YANG));
+    assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, schema_a, LYS_IN_YANG, NULL));
 
     return 0;
 }
@@ -193,7 +193,7 @@
     assert_int_equal(LYS_ANYDATA, tree->schema->nodetype);
     assert_string_equal("any", tree->schema->name);
 
-    lyd_print(out, tree, LYD_XML, 0);
+    lyd_print_tree(out, tree, LYD_XML, 0);
     assert_string_equal(str,
         "<any xmlns=\"urn:tests:a\">"
             "<element1>"
@@ -343,7 +343,7 @@
     assert_string_equal(((struct lyd_node_opaq *)tree)->name, "foo3");
     assert_string_equal(((struct lyd_node_opaq *)tree)->value, "");
 
-    lyd_print(out, tree, LYD_XML, 0);
+    lyd_print_tree(out, tree, LYD_XML, 0);
     assert_string_equal(str, "<foo3 xmlns=\"urn:tests:a\"/>");
     ly_out_reset(out);
     lyd_free_all(tree);
@@ -361,7 +361,7 @@
     assert_string_equal(((struct lyd_node_opaq *)tree)->name, "l1");
     assert_string_equal(((struct lyd_node_opaq *)tree)->value, "");
 
-    lyd_print(out, tree, LYD_XML, 0);
+    lyd_print_tree(out, tree, LYD_XML, 0);
     assert_string_equal(str, data);
     ly_out_reset(out);
     lyd_free_all(tree);
@@ -379,7 +379,7 @@
     assert_string_equal(((struct lyd_node_opaq *)tree)->name, "l1");
     assert_string_equal(((struct lyd_node_opaq *)tree)->value, "");
 
-    lyd_print(out, tree, LYD_XML, 0);
+    lyd_print_tree(out, tree, LYD_XML, 0);
     assert_string_equal(str, data);
     ly_out_reset(out);
     lyd_free_all(tree);
@@ -453,7 +453,7 @@
     assert_null(node->schema);
     assert_string_equal(((struct lyd_node_opaq *)node)->name, "z");
 
-    lyd_print(out, tree, LYD_XML, 0);
+    lyd_print_tree(out, tree, LYD_XML, 0);
     assert_string_equal(str,
         "<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" msgid=\"25\" custom-attr=\"val\">"
             "<edit-config>"
@@ -523,7 +523,7 @@
     assert_string_equal(((struct lyd_node_opaq *)node)->name, "action");
     assert_null(((struct lyd_node_opaq *)node)->attr);
 
-    lyd_print(out, tree, LYD_XML, 0);
+    lyd_print_tree(out, tree, LYD_XML, 0);
     assert_string_equal(str,
         "<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" msgid=\"25\" custom-attr=\"val\">"
             "<action xmlns=\"urn:ietf:params:xml:ns:yang:1\">"
@@ -588,7 +588,7 @@
     assert_non_null(node->schema);
     assert_string_equal(node->schema->name, "c");
 
-    lyd_print(out, tree, LYD_XML, 0);
+    lyd_print_tree(out, tree, LYD_XML, 0);
     assert_string_equal(str, data);
     ly_out_reset(out);
     lyd_free_all(tree);
@@ -605,7 +605,7 @@
     assert_non_null(tree);
     assert_ptr_equal(ntf, tree);
 
-    lyd_print(out, tree, LYD_XML, 0);
+    lyd_print_tree(out, tree, LYD_XML, 0);
     assert_string_equal(str, data);
     ly_out_reset(out);
     lyd_free_all(tree);
@@ -667,7 +667,7 @@
     assert_string_equal(node->schema->name, "c");
 
     /* TODO print only rpc-reply node and then output subtree */
-    lyd_print(out, lyd_node_children(op, 0), LYD_XML, 0);
+    lyd_print_tree(out, lyd_node_children(op, 0), LYD_XML, 0);
     assert_string_equal(str,
         "<al xmlns=\"urn:tests:a\">25</al>");
     ly_out_reset(out);
diff --git a/tests/utests/data/test_printer_xml.c b/tests/utests/data/test_printer_xml.c
index 7f44fb4..f6d8089 100644
--- a/tests/utests/data/test_printer_xml.c
+++ b/tests/utests/data/test_printer_xml.c
@@ -132,9 +132,9 @@
 
     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(lys_parse_mem(s->ctx, schema_a, LYS_IN_YANG));
-    assert_non_null(lys_parse_mem(s->ctx, schema_b, LYS_IN_YANG));
-    assert_non_null(lys_parse_mem(s->ctx, schema_c, LYS_IN_YANG));
+    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));
 
     *state = s;
 
@@ -186,7 +186,7 @@
     data = "<int8 xmlns=\"urn:tests:types\">\n 15 \t\n  </int8>";
     result = "<int8 xmlns=\"urn:tests:types\">15</int8>";
     assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(s->ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
-    assert_int_equal(LY_SUCCESS, lyd_print(out, tree, LYD_XML, 0));
+    assert_int_equal(LY_SUCCESS, lyd_print_tree(out, tree, LYD_XML, 0));
     assert_int_equal(strlen(printed), ly_out_printed(out));
     assert_string_equal(printed, result);
     lyd_free_all(tree);
@@ -209,7 +209,7 @@
 
     data = "<any xmlns=\"urn:tests:types\"><somexml xmlns:x=\"url:x\" xmlns=\"example.com\"><x:x/></somexml></any>";
     assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(s->ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
-    assert_int_equal(LY_SUCCESS, lyd_print(out, tree, LYD_XML, 0));
+    assert_int_equal(LY_SUCCESS, lyd_print_tree(out, tree, LYD_XML, 0));
     assert_int_equal(strlen(printed), ly_out_printed(out));
     /* canonized */
     data = "<any xmlns=\"urn:tests:types\"><somexml xmlns=\"example.com\"><x xmlns=\"url:x\"/></somexml></any>";
@@ -219,7 +219,7 @@
 
     data = "<any xmlns=\"urn:tests:types\"/>";
     assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(s->ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
-    assert_int_equal(LY_SUCCESS, lyd_print(out, tree, LYD_XML, 0));
+    assert_int_equal(LY_SUCCESS, lyd_print_tree(out, tree, LYD_XML, 0));
     assert_int_equal(strlen(printed), ly_out_printed(out));
     assert_string_equal(printed, data);
     ly_out_reset(out);
@@ -241,7 +241,7 @@
     assert_string_equal(((struct lyd_node_any *)tree)->value.tree->schema->name, "cont");
     /* but its children not */
     assert_null(((struct lyd_node_inner *)(((struct lyd_node_any *)tree)->value.tree))->child->schema);
-    assert_int_equal(LY_SUCCESS, lyd_print(out, tree, LYD_XML, 0));
+    assert_int_equal(LY_SUCCESS, lyd_print_tree(out, tree, LYD_XML, 0));
     assert_int_equal(strlen(printed), ly_out_printed(out));
     /* canonized */
     data =
@@ -279,18 +279,18 @@
     data = "<c xmlns=\"urn:defaults\">aa</c>";
     assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(s->ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
 
-    assert_int_equal(LY_SUCCESS, lyd_print(out, tree, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_TRIM));
+    assert_int_equal(LY_SUCCESS, lyd_print_all(out, tree, LYD_XML, LYD_PRINT_WD_TRIM));
     assert_int_equal(strlen(printed), ly_out_printed(out));
     assert_string_equal(printed, data);
     ly_out_reset(out);
 
-    assert_int_equal(LY_SUCCESS, lyd_print(out, tree, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_ALL));
+    assert_int_equal(LY_SUCCESS, lyd_print_all(out, tree, LYD_XML, LYD_PRINT_WD_ALL));
     assert_int_equal(strlen(printed), ly_out_printed(out));
     data = "<c xmlns=\"urn:defaults\">aa</c><a xmlns=\"urn:defaults\" xmlns:d=\"urn:defaults\">/d:b</a>";
     assert_string_equal(printed, data);
     ly_out_reset(out);
 
-    assert_int_equal(LY_SUCCESS, lyd_print(out, tree, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_ALL_TAG));
+    assert_int_equal(LY_SUCCESS, lyd_print_all(out, tree, LYD_XML, LYD_PRINT_WD_ALL_TAG));
     assert_int_equal(strlen(printed), ly_out_printed(out));
     data = "<c xmlns=\"urn:defaults\">aa</c>"
         "<a xmlns=\"urn:defaults\" xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\""
@@ -298,7 +298,7 @@
     assert_string_equal(printed, data);
     ly_out_reset(out);
 
-    assert_int_equal(LY_SUCCESS, lyd_print(out, tree, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_IMPL_TAG));
+    assert_int_equal(LY_SUCCESS, lyd_print_all(out, tree, LYD_XML, LYD_PRINT_WD_IMPL_TAG));
     assert_int_equal(strlen(printed), ly_out_printed(out));
     data = "<c xmlns=\"urn:defaults\">aa</c>"
         "<a xmlns=\"urn:defaults\" xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\""
@@ -312,22 +312,22 @@
     data = "<c xmlns=\"urn:defaults\">aa</c><a xmlns=\"urn:defaults\">/d:b</a>";
     assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(s->ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
 
-    assert_int_equal(LY_SUCCESS, lyd_print(out, tree, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_TRIM));
+    assert_int_equal(LY_SUCCESS, lyd_print_all(out, tree, LYD_XML, LYD_PRINT_WD_TRIM));
     assert_int_equal(strlen(printed), ly_out_printed(out));
     assert_string_equal(printed, data);
     ly_out_reset(out);
 
-    assert_int_equal(LY_SUCCESS, lyd_print(out, tree, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_ALL));
+    assert_int_equal(LY_SUCCESS, lyd_print_all(out, tree, LYD_XML, LYD_PRINT_WD_ALL));
     assert_int_equal(strlen(printed), ly_out_printed(out));
     assert_string_equal(printed, data);
     ly_out_reset(out);
 
-    assert_int_equal(LY_SUCCESS, lyd_print(out, tree, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_ALL_TAG));
+    assert_int_equal(LY_SUCCESS, lyd_print_all(out, tree, LYD_XML, LYD_PRINT_WD_ALL_TAG));
     assert_int_equal(strlen(printed), ly_out_printed(out));
     assert_string_equal(printed, data);
     ly_out_reset(out);
 
-    assert_int_equal(LY_SUCCESS, lyd_print(out, tree, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_IMPL_TAG));
+    assert_int_equal(LY_SUCCESS, lyd_print_all(out, tree, LYD_XML, LYD_PRINT_WD_IMPL_TAG));
     assert_int_equal(strlen(printed), ly_out_printed(out));
     assert_string_equal(printed, data);
     ly_out_reset(out);
@@ -338,19 +338,19 @@
     data = "<c xmlns=\"urn:defaults\">aa</c><a xmlns=\"urn:defaults\" xmlns:d=\"urn:defaults\">/d:b</a><b xmlns=\"urn:defaults\">val</b>";
     assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(s->ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
 
-    assert_int_equal(LY_SUCCESS, lyd_print(out, tree, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_TRIM));
+    assert_int_equal(LY_SUCCESS, lyd_print_all(out, tree, LYD_XML, LYD_PRINT_WD_TRIM));
     assert_int_equal(strlen(printed), ly_out_printed(out));
     data = "<c xmlns=\"urn:defaults\">aa</c><b xmlns=\"urn:defaults\">val</b>";
     assert_string_equal(printed, data);
     ly_out_reset(out);
 
-    assert_int_equal(LY_SUCCESS, lyd_print(out, tree, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_ALL));
+    assert_int_equal(LY_SUCCESS, lyd_print_all(out, tree, LYD_XML, LYD_PRINT_WD_ALL));
     assert_int_equal(strlen(printed), ly_out_printed(out));
     data = "<c xmlns=\"urn:defaults\">aa</c><a xmlns=\"urn:defaults\" xmlns:d=\"urn:defaults\">/d:b</a><b xmlns=\"urn:defaults\">val</b>";
     assert_string_equal(printed, data);
     ly_out_reset(out);
 
-    assert_int_equal(LY_SUCCESS, lyd_print(out, tree, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_ALL_TAG));
+    assert_int_equal(LY_SUCCESS, lyd_print_all(out, tree, LYD_XML, LYD_PRINT_WD_ALL_TAG));
     assert_int_equal(strlen(printed), ly_out_printed(out));
     data = "<c xmlns=\"urn:defaults\">aa</c>"
         "<a xmlns=\"urn:defaults\" xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\""
@@ -359,7 +359,7 @@
     assert_string_equal(printed, data);
     ly_out_reset(out);
 
-    assert_int_equal(LY_SUCCESS, lyd_print(out, tree, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_IMPL_TAG));
+    assert_int_equal(LY_SUCCESS, lyd_print_all(out, tree, LYD_XML, LYD_PRINT_WD_IMPL_TAG));
     assert_int_equal(strlen(printed), ly_out_printed(out));
     data = "<c xmlns=\"urn:defaults\">aa</c><a xmlns=\"urn:defaults\" xmlns:d=\"urn:defaults\">/d:b</a><b xmlns=\"urn:defaults\">val</b>";
     assert_string_equal(printed, data);
@@ -393,13 +393,13 @@
     reply = "<result xmlns=\"urn:tests:types\">30</result>";
     result = "<sum xmlns=\"urn:tests:types\"><result>30</result></sum>";
     assert_non_null(tree1 = lyd_parse_mem(s->ctx, request, LYD_XML, LYD_OPT_RPC, NULL));
-    assert_true((len = lyd_print(out, tree1, LYD_XML, 0)) >= 0);
+    assert_true((len = lyd_print_tree(out, tree1, LYD_XML, 0)) >= 0);
     assert_int_equal(len, strlen(printed));
     assert_string_equal(printed, request);
     ly_out_reset(out);
     assert_non_null(trees = lyd_trees_new(1, tree1));
     assert_non_null(tree2 = lyd_parse_mem(s->ctx, reply, LYD_XML, LYD_OPT_RPCREPLY, trees));
-    assert_true((len = lyd_print(out, tree2, LYD_XML, 0)) >= 0);
+    assert_true((len = lyd_print_tree(out, tree2, LYD_XML, 0)) >= 0);
     assert_int_equal(len, strlen(printed));
     assert_string_equal(printed, result);
     ly_out_reset(out);
@@ -412,13 +412,13 @@
     reply = "";
     result = "<sum xmlns=\"urn:tests:types\"/>";
     assert_non_null(tree1 = lyd_parse_mem(s->ctx, request, LYD_XML, LYD_OPT_RPC, NULL));
-    assert_true((len = lyd_print(out, tree1, LYD_XML, 0)) >= 0);
+    assert_true((len = lyd_print_tree(out, tree1, LYD_XML, 0)) >= 0);
     assert_int_equal(len, strlen(printed));
     assert_string_equal(printed, request);
     ly_out_reset(out);
     assert_non_null(trees = lyd_trees_new(1, tree1));
     assert_non_null(tree2 = lyd_parse_mem(s->ctx, reply, LYD_XML, LYD_OPT_RPCREPLY, trees));
-    assert_true((len = lyd_print(out, tree2, LYD_XML, 0)) >= 0);
+    assert_true((len = lyd_print_tree(out, tree2, LYD_XML, 0)) >= 0);
     assert_int_equal(len, strlen(printed));
     assert_string_equal(printed, result);
     ly_out_reset(out);
@@ -436,13 +436,13 @@
     reply = "<b xmlns=\"urn:tests:types\">test-reply</b>";
     result = "<cont xmlns=\"urn:tests:types\"><listtarget><id>10</id><test><b>test-reply</b></test></listtarget></cont>";;
     assert_non_null(tree1 = lyd_parse_mem(s->ctx, request, LYD_XML, LYD_OPT_RPC, NULL));
-    assert_true((len = lyd_print(out, tree1, LYD_XML, 0)) >= 0);
+    assert_true((len = lyd_print_tree(out, tree1, LYD_XML, 0)) >= 0);
     assert_int_equal(len, strlen(printed));
     assert_string_equal(printed, request);
     ly_out_reset(out);
     assert_non_null(trees = lyd_trees_new(1, tree1));
     assert_non_null(tree2 = lyd_parse_mem(s->ctx, reply, LYD_XML, LYD_OPT_RPCREPLY, trees));
-    assert_true((len = lyd_print(out, tree2, LYD_XML, 0)) >= 0);
+    assert_true((len = lyd_print_tree(out, tree2, LYD_XML, 0)) >= 0);
     assert_int_equal(len, strlen(printed));
     assert_string_equal(printed, result);
     ly_out_reset(out);
diff --git a/tests/utests/data/test_tree_data.c b/tests/utests/data/test_tree_data.c
index 31f0488..fbf888a 100644
--- a/tests/utests/data/test_tree_data.c
+++ b/tests/utests/data/test_tree_data.c
@@ -65,7 +65,7 @@
 #endif
 
     assert_int_equal(LY_SUCCESS, ly_ctx_new(NULL, 0, &ctx));
-    assert_non_null(lys_parse_mem(ctx, schema_a, LYS_IN_YANG));
+    assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, schema_a, LYS_IN_YANG, NULL));
 
     return 0;
 }
@@ -182,7 +182,7 @@
     const char *data = "<l1 xmlns=\"urn:tests:a\"><a>a</a><b>b</b><c>x</c></l1>";
 
     assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree1));
-    assert_non_null(tree2 = lyd_dup(tree1, NULL, LYD_DUP_RECURSIVE));
+    assert_int_equal(LY_SUCCESS, lyd_dup_single(tree1, NULL, LYD_DUP_RECURSIVE, &tree2));
     assert_int_equal(LY_SUCCESS, lyd_compare(tree1, tree2, LYD_COMPARE_FULL_RECURSION));
     lyd_free_all(tree1);
     lyd_free_all(tree2);
@@ -190,7 +190,7 @@
     data = "<l1 xmlns=\"urn:tests:a\"><a>a</a><b>b</b><c>x</c></l1>";
     result = "<l1 xmlns=\"urn:tests:a\"><a>a</a><b>b</b></l1>";
     assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree1));
-    assert_non_null(tree2 = lyd_dup(tree1, NULL, 0));
+    assert_int_equal(LY_SUCCESS, lyd_dup_single(tree1, NULL, 0, &tree2));
     lyd_free_all(tree1);
     assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, result, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree1));
     assert_int_equal(LY_SUCCESS, lyd_compare(tree1, tree2, LYD_COMPARE_FULL_RECURSION));
@@ -200,16 +200,16 @@
     data = "<l2 xmlns=\"urn:tests:a\"><c><x>a</x></c></l2><l2 xmlns=\"urn:tests:a\"><c><x>b</x></c></l2>";
     result = "<l2 xmlns=\"urn:tests:a\"><c><x>a</x></c></l2>";
     assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree1));
-    assert_non_null(tree2 = lyd_dup(tree1, NULL, LYD_DUP_WITH_SIBLINGS | LYD_DUP_RECURSIVE));
+    assert_int_equal(LY_SUCCESS, lyd_dup_siblings(tree1, NULL, LYD_DUP_RECURSIVE, &tree2));
     assert_int_equal(LY_SUCCESS, lyd_compare(tree1, tree2, LYD_COMPARE_FULL_RECURSION));
     lyd_free_all(tree2);
-    assert_non_null(tree2 = lyd_dup(tree1, NULL, LYD_DUP_RECURSIVE));
+    assert_int_equal(LY_SUCCESS, lyd_dup_single(tree1, NULL, LYD_DUP_RECURSIVE, &tree2));
     lyd_free_all(tree1);
     assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, result, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree1));
     assert_int_equal(LY_SUCCESS, lyd_compare(tree1, tree2, LYD_COMPARE_FULL_RECURSION));
     lyd_free_all(tree2);
 
-    assert_non_null(tree2 = lyd_dup(tree1, NULL, 0));
+    assert_int_equal(LY_SUCCESS, lyd_dup_single(tree1, NULL, 0, &tree2));
     lyd_free_all(tree1);
     result = "<l2 xmlns=\"urn:tests:a\"/>";
     assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, result, LYD_XML, LYD_PARSE_ONLY, 0, &tree1));
@@ -219,14 +219,15 @@
 
     data = "<any xmlns=\"urn:tests:a\"><c><a>a</a></c></any>";
     assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree1));
-    assert_non_null(tree2 = lyd_dup(tree1, NULL, 0));
+    assert_int_equal(LY_SUCCESS, lyd_dup_single(tree1, NULL, 0, &tree2));
     assert_int_equal(LY_SUCCESS, lyd_compare(tree1, tree2, LYD_COMPARE_FULL_RECURSION));
     lyd_free_all(tree1);
     lyd_free_all(tree2);
 
     data = "<l2 xmlns=\"urn:tests:a\"><c><x>b</x></c></l2>";
     assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree1));
-    assert_non_null(tree2 = lyd_dup(((struct lyd_node_inner*)((struct lyd_node_inner*)tree1)->child)->child, NULL, LYD_DUP_WITH_PARENTS));
+    assert_int_equal(LY_SUCCESS, lyd_dup_single(((struct lyd_node_inner*)((struct lyd_node_inner*)tree1)->child)->child, NULL,
+                                         LYD_DUP_WITH_PARENTS, &tree2));
     assert_string_equal("x", tree2->schema->name);
     assert_non_null(tree2->parent);
     assert_int_equal(LY_SUCCESS, lyd_compare(tree1, (struct lyd_node*)tree2->parent->parent, LYD_COMPARE_FULL_RECURSION));
@@ -235,7 +236,8 @@
 
     data = "<l1 xmlns=\"urn:tests:a\"><a>a</a><b>b</b><c>c</c></l1>";
     assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree1));
-    assert_non_null(tree2 = lyd_dup(((struct lyd_node_inner*)tree1)->child->prev, NULL, LYD_DUP_WITH_PARENTS));
+    assert_int_equal(LY_SUCCESS, lyd_dup_single(((struct lyd_node_inner*)tree1)->child->prev, NULL,
+                                                LYD_DUP_WITH_PARENTS, &tree2));
     assert_string_equal("c", tree2->schema->name);
     assert_non_null(tree2->parent);
     assert_int_equal(LY_SUCCESS, lyd_compare(tree1, (struct lyd_node*)tree2->parent, LYD_COMPARE_FULL_RECURSION));
@@ -244,9 +246,9 @@
 
     data = "<l2 xmlns=\"urn:tests:a\"><c><x>b</x></c></l2>";
     assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree1));
-    assert_non_null(tree2 = lyd_dup(tree1, NULL, 0));
-    assert_non_null(lyd_dup(((struct lyd_node_inner*)((struct lyd_node_inner*)tree1)->child)->child,
-                            (struct lyd_node_inner*)tree2, LYD_DUP_WITH_PARENTS));
+    assert_int_equal(LY_SUCCESS, lyd_dup_single(tree1, NULL, 0, &tree2));
+    assert_int_equal(LY_SUCCESS, lyd_dup_single(((struct lyd_node_inner*)((struct lyd_node_inner*)tree1)->child)->child,
+                                 (struct lyd_node_inner*)tree2, LYD_DUP_WITH_PARENTS, NULL));
     assert_int_equal(LY_SUCCESS, lyd_compare(tree1, tree2, LYD_COMPARE_FULL_RECURSION));
     lyd_free_all(tree1);
     lyd_free_all(tree2);
@@ -254,7 +256,8 @@
     /* invalid */
     data = "<l1 xmlns=\"urn:tests:a\"><a>a</a><b>b</b><c>c</c></l1><l2 xmlns=\"urn:tests:a\"><c><x>b</x></c></l2>";
     assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree1));
-    assert_null(lyd_dup(((struct lyd_node_inner*)tree1)->child->prev, (struct lyd_node_inner*)tree1->next, LYD_DUP_WITH_PARENTS));
+    assert_int_equal(LY_EINVAL, lyd_dup_single(((struct lyd_node_inner*)tree1)->child->prev,
+                                               (struct lyd_node_inner*)tree1->next, LYD_DUP_WITH_PARENTS, NULL));
     lyd_free_all(tree1);
 
     *state = NULL;
diff --git a/tests/utests/data/test_types.c b/tests/utests/data/test_types.c
index 6d8de5f..6d223dc 100644
--- a/tests/utests/data/test_types.c
+++ b/tests/utests/data/test_types.c
@@ -113,8 +113,8 @@
 #endif
 
     assert_int_equal(LY_SUCCESS, ly_ctx_new(NULL, 0, &s->ctx));
-    assert_non_null(lys_parse_mem(s->ctx, schema_a, LYS_IN_YANG));
-    assert_non_null(lys_parse_mem(s->ctx, schema_b, LYS_IN_YANG));
+    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));
 
     *state = s;
 
@@ -897,7 +897,7 @@
 
     TEST_DATA("<t:inst-noreq xmlns:t=\"urn:tests:types\">/t:cont/t:listtarget[t:value='x']</t:inst-noreq>", LY_EVALID,
               "Invalid instance-identifier \"/t:cont/t:listtarget[t:value='x']\" value - semantic error. /types:inst-noreq");
-    TEST_DATA("<t:inst-noreq xmlns:t=\"urn:tests:types\">/t:cont/t:listtarget[t:x='x']</t:inst-noreq>", LY_EVALID,
+    TEST_DATA("<t:inst-noreq xmlns:t=\"urn:tests:types\">/t:cont/t:listtarget[t:x='x']</t:inst-noreq>", LY_ENOTFOUND,
               "Invalid instance-identifier \"/t:cont/t:listtarget[t:x='x']\" value - semantic error. /types:inst-noreq");
     TEST_DATA("<cont xmlns=\"urn:tests:types\"><listtarget><id>1</id><value>x</value></listtarget></cont>"
               "<t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:listtarget[.='x']</t:inst>", LY_EVALID,
@@ -990,7 +990,7 @@
             "}}}";
 
     /* additional schema */
-    assert_non_null(lys_parse_mem(s->ctx, schema, LYS_IN_YANG));
+    assert_int_equal(LY_SUCCESS, lys_parse_mem(s->ctx, schema, LYS_IN_YANG, NULL));
 
     /* valid data */
     TEST_DATA("<leaflisttarget xmlns=\"urn:tests:types\">x</leaflisttarget><leaflisttarget xmlns=\"urn:tests:types\">y</leaflisttarget><lref xmlns=\"urn:tests:types\">y</lref>", LY_SUCCESS, "");
diff --git a/tests/utests/data/test_validation.c b/tests/utests/data/test_validation.c
index da68a40..e0c4de8 100644
--- a/tests/utests/data/test_validation.c
+++ b/tests/utests/data/test_validation.c
@@ -419,16 +419,16 @@
 
     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(lys_parse_mem(ctx, schema_a, LYS_IN_YANG));
-    assert_non_null(lys_parse_mem(ctx, schema_b, LYS_IN_YANG));
-    assert_non_null(lys_parse_mem(ctx, schema_c, LYS_IN_YANG));
-    assert_non_null(lys_parse_mem(ctx, schema_d, LYS_IN_YANG));
-    assert_non_null(lys_parse_mem(ctx, schema_e, LYS_IN_YANG));
-    assert_non_null(lys_parse_mem(ctx, schema_f, LYS_IN_YANG));
-    assert_non_null(lys_parse_mem(ctx, schema_g, LYS_IN_YANG));
-    assert_non_null(lys_parse_mem(ctx, schema_h, LYS_IN_YANG));
-    assert_non_null(lys_parse_mem(ctx, schema_i, LYS_IN_YANG));
-    assert_non_null(lys_parse_mem(ctx, schema_j, LYS_IN_YANG));
+    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));
+    assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, schema_d, LYS_IN_YANG, NULL));
+    assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, schema_e, LYS_IN_YANG, NULL));
+    assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, schema_f, LYS_IN_YANG, NULL));
+    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));
 
     return 0;
 }
@@ -1032,7 +1032,7 @@
     assert_non_null(diff);
 
     /* check all defaults exist */
-    lyd_print(out, tree, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_IMPL_TAG);
+    lyd_print_all(out, tree, LYD_XML, LYD_PRINT_WD_IMPL_TAG);
     assert_string_equal(str,
         "<ll1 xmlns=\"urn:tests:f\" xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def1</ll1>"
         "<ll1 xmlns=\"urn:tests:f\" xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def2</ll1>"
@@ -1051,7 +1051,7 @@
     ly_out_reset(out);
 
     /* check diff */
-    lyd_print(out, diff, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_ALL);
+    lyd_print_all(out, diff, LYD_XML, LYD_PRINT_WD_ALL);
     assert_string_equal(str,
         "<ll1 xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"create\">def1</ll1>"
         "<ll1 xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"create\">def2</ll1>"
@@ -1072,13 +1072,12 @@
     lyd_free_siblings(diff);
 
     /* create another explicit case and validate */
-    node = lyd_new_term(NULL, mod, "l", "value");
-    assert_non_null(node);
+    assert_int_equal(lyd_new_term(NULL, mod, "l", "value", &node), LY_SUCCESS);
     assert_int_equal(lyd_insert_sibling(tree, node), LY_SUCCESS);
-    assert_int_equal(lyd_validate(&tree, ctx, LYD_VALIDATE_PRESENT, &diff), LY_SUCCESS);
+    assert_int_equal(lyd_validate_all(&tree, ctx, LYD_VALIDATE_PRESENT, &diff), LY_SUCCESS);
 
     /* check data tree */
-    lyd_print(out, tree, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_IMPL_TAG);
+    lyd_print_all(out, tree, LYD_XML, LYD_PRINT_WD_IMPL_TAG);
     assert_string_equal(str,
         "<d xmlns=\"urn:tests:f\" xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">15</d>"
         "<ll2 xmlns=\"urn:tests:f\" xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt1</ll2>"
@@ -1095,7 +1094,7 @@
     ly_out_reset(out);
 
     /* check diff */
-    lyd_print(out, diff, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_ALL);
+    lyd_print_all(out, diff, LYD_XML, LYD_PRINT_WD_ALL);
     assert_string_equal(str,
         "<ll1 xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"delete\">def1</ll1>"
         "<ll1 xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"delete\">def2</ll1>"
@@ -1105,16 +1104,14 @@
     lyd_free_siblings(diff);
 
     /* create explicit leaf-list and leaf and validate */
-    node = lyd_new_term(NULL, mod, "d", "15");
-    assert_non_null(node);
+    assert_int_equal(lyd_new_term(NULL, mod, "d", "15", &node), LY_SUCCESS);
     assert_int_equal(lyd_insert_sibling(tree, node), LY_SUCCESS);
-    node = lyd_new_term(NULL, mod, "ll2", "dflt2");
-    assert_non_null(node);
+    assert_int_equal(lyd_new_term(NULL, mod, "ll2", "dflt2", &node), LY_SUCCESS);
     assert_int_equal(lyd_insert_sibling(tree, node), LY_SUCCESS);
-    assert_int_equal(lyd_validate(&tree, ctx, LYD_VALIDATE_PRESENT, &diff), LY_SUCCESS);
+    assert_int_equal(lyd_validate_all(&tree, ctx, LYD_VALIDATE_PRESENT, &diff), LY_SUCCESS);
 
     /* check data tree */
-    lyd_print(out, tree, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_IMPL_TAG);
+    lyd_print_all(out, tree, LYD_XML, LYD_PRINT_WD_IMPL_TAG);
     assert_string_equal(str,
         "<cont xmlns=\"urn:tests:f\">"
             "<ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def1</ll1>"
@@ -1130,7 +1127,7 @@
     ly_out_reset(out);
 
     /* check diff */
-    lyd_print(out, diff, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_ALL);
+    lyd_print_all(out, diff, LYD_XML, LYD_PRINT_WD_ALL);
     assert_string_equal(str,
         "<d xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"delete\">15</d>"
         "<ll2 xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"delete\">dflt1</ll2>"
@@ -1140,14 +1137,13 @@
     lyd_free_siblings(diff);
 
     /* create first explicit container, which should become implicit */
-    node = lyd_new_inner(NULL, mod, "cont");
-    assert_non_null(node);
+    assert_int_equal(lyd_new_inner(NULL, mod, "cont", &node), LY_SUCCESS);
     assert_int_equal(lyd_insert_before(tree, node), LY_SUCCESS);
     tree = tree->prev;
-    assert_int_equal(lyd_validate(&tree, ctx, LYD_VALIDATE_PRESENT, &diff), LY_SUCCESS);
+    assert_int_equal(lyd_validate_all(&tree, ctx, LYD_VALIDATE_PRESENT, &diff), LY_SUCCESS);
 
     /* check data tree */
-    lyd_print(out, tree, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_IMPL_TAG);
+    lyd_print_all(out, tree, LYD_XML, LYD_PRINT_WD_IMPL_TAG);
     assert_string_equal(str,
         "<cont xmlns=\"urn:tests:f\">"
             "<ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def1</ll1>"
@@ -1166,13 +1162,12 @@
     assert_null(diff);
 
     /* create second explicit container, which should become implicit, so the first tree node should be removed */
-    node = lyd_new_inner(NULL, mod, "cont");
-    assert_non_null(node);
+    assert_int_equal(lyd_new_inner(NULL, mod, "cont", &node), LY_SUCCESS);
     assert_int_equal(lyd_insert_after(tree, node), LY_SUCCESS);
-    assert_int_equal(lyd_validate(&tree, ctx, LYD_VALIDATE_PRESENT, &diff), LY_SUCCESS);
+    assert_int_equal(lyd_validate_all(&tree, ctx, LYD_VALIDATE_PRESENT, &diff), LY_SUCCESS);
 
     /* check data tree */
-    lyd_print(out, tree, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_IMPL_TAG);
+    lyd_print_all(out, tree, LYD_XML, LYD_PRINT_WD_IMPL_TAG);
     assert_string_equal(str,
         "<cont xmlns=\"urn:tests:f\">"
             "<ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def1</ll1>"
@@ -1191,13 +1186,13 @@
     assert_null(diff);
 
     /* similar changes for nested defaults */
-    assert_non_null(lyd_new_term(tree, NULL, "ll1", "def3"));
-    assert_non_null(lyd_new_term(tree, NULL, "d", "5"));
-    assert_non_null(lyd_new_term(tree, NULL, "ll2", "non-dflt"));
-    assert_int_equal(lyd_validate(&tree, ctx, LYD_VALIDATE_PRESENT, &diff), LY_SUCCESS);
+    assert_int_equal(lyd_new_term(tree, NULL, "ll1", "def3", NULL), LY_SUCCESS);
+    assert_int_equal(lyd_new_term(tree, NULL, "d", "5", NULL), LY_SUCCESS);
+    assert_int_equal(lyd_new_term(tree, NULL, "ll2", "non-dflt", NULL), LY_SUCCESS);
+    assert_int_equal(lyd_validate_all(&tree, ctx, LYD_VALIDATE_PRESENT, &diff), LY_SUCCESS);
 
     /* check data tree */
-    lyd_print(out, tree, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_IMPL_TAG);
+    lyd_print_all(out, tree, LYD_XML, LYD_PRINT_WD_IMPL_TAG);
     assert_string_equal(str,
         "<cont xmlns=\"urn:tests:f\">"
             "<ll1>def3</ll1>"
@@ -1210,7 +1205,7 @@
     ly_out_reset(out);
 
     /* check diff */
-    lyd_print(out, diff, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_ALL);
+    lyd_print_all(out, diff, LYD_XML, LYD_PRINT_WD_ALL);
     assert_string_equal(str,
         "<cont xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">"
             "<ll1 yang:operation=\"delete\">def1</ll1>"
@@ -1319,17 +1314,17 @@
     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(&tree, NULL, LYD_VALIDATE_PRESENT, NULL));
+    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(&tree, NULL, LYD_VALIDATE_PRESENT, NULL));
+    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(&tree, NULL, LYD_VALIDATE_PRESENT, NULL));
+    assert_int_equal(LY_SUCCESS, lyd_validate_all(&tree, NULL, LYD_VALIDATE_PRESENT, NULL));
 
     lyd_free_siblings(tree);
 
@@ -1361,7 +1356,7 @@
     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(&tree, NULL, LYD_VALIDATE_PRESENT | LYD_VALIDATE_NO_STATE, NULL));
+    assert_int_equal(LY_EVALID, lyd_validate_all(&tree, NULL, LYD_VALIDATE_PRESENT | LYD_VALIDATE_NO_STATE, NULL));
     logbuf_assert("Invalid state data node \"cont2\" found. /h:cont/cont2");
 
     lyd_free_siblings(tree);