Improve red/nodes/Node.js coverage and minor refactoring

I've added a couple of tests, refactored common code and simplified the null case behaviour.

I wasn't sure if the test for the null messages case was a reasonable approach or if there was a better way to test this. But I wanted to test it because I wanted to change the implementation and this was the best I could come up with.

I'm new to javascript and not so if there is a better way then I'm happy to re-work the changes.

Regards,
-Mark