fixed JS print output
more cases for issue #324