#vulnerable code 
                             @Test
	public void testAppendTo() {
		String parentHtml = "<div class='a'></div>";
		String childHtml = "<div class='b'></div>";

		Element parentElement = Jsoup.parse(parentHtml).getElementsByClass("a").first();
		Element childElement = Jsoup.parse(childHtml).getElementsByClass("b").first();

		childElement.attr("class", "test-class").appendTo(parentElement).attr("id", "testId");
		assertEquals("test-class", childElement.attr("class"));
		assertEquals("testId", childElement.attr("id"));
		assertThat(parentElement.attr("id"), not(equalTo("testId")));
		assertThat(parentElement.attr("class"), not(equalTo("test-class")));
		assertSame(childElement, parentElement.children().first());
		assertSame(parentElement, childElement.parent());
	} 
                            #location 9 
                            #vulnerability type NULL_DEREFERENCE
#fixed code
                             @Test
	public void testAppendTo() {
		String parentHtml = "<div class='a'></div>";
		String childHtml = "<div class='b'></div><p>Two</p>";

		Document parentDoc = Jsoup.parse(parentHtml);
		Element parent = parentDoc.body();
        Document childDoc = Jsoup.parse(childHtml);

        Element div = childDoc.select("div").first();
        Element p = childDoc.select("p").first();
        Element appendTo1 = div.appendTo(parent);
        assertEquals(div, appendTo1);

        Element appendTo2 = p.appendTo(div);
        assertEquals(p, appendTo2);

        assertEquals("<div class=\"a\"></div>\n<div class=\"b\">\n <p>Two</p>\n</div>", parentDoc.body().html());
        assertEquals("", childDoc.body().html()); // got moved out
	}