You could stub document.getElementById instead of creating these elements.