When you call setInterval, you must supply a function. You're calling the function immediately, not passing the function to setInterval. It should be:
setInterval(test, 1000);
Since you're calling it immediately, it's running before the DOM has loaded fully, and the td1 element isn't found. So getElementById returns null instead of the element.
In addition, as the other answers pointed out, you should not use [0] to access the element returned by getElementById. It returns a single element, not a NodeList.