var wrapper = $('<p><div class="text">Hello World</div></p>');
console.log(wrapper.html());
Becomes
<p></p><div class="text">SOMETHING</div><p></p>
How can you avoid the HTML being messed up like that?
ANSWER : I did not realize putting a DIV inside a paragraph was invalid HTML.