It seems that the test function doens't care what is printed on the screen the thing that matters is that the function is correct and that you call the function. That is what the first one does and therefore it is ok if you print other stuff as well or don't use the returned message it is not important. The problem with the second one is not the output, as said that doesn't matter but that you use a different output message:
"Hi, I am"+ " " +name
"Hi, I am " + " " +name
so you added 2 spaces instead of one for the 2nd version.