You need to visualize the DOM structure of your element <div id="test">. It contains three children:
Node text containing only space.
An element <p>that contains node text that matters h.
The text node that matters ello.
, <p> ello node, l. :
var range = document.createRange();
var root_node = document.getElementById("test");
range.setStart(root_node, 1);
range.setEnd(root_node.childNodes[2], 2);
var newNode = document.createElement("b");
range.surroundContents(newNode);
fiddle.