Bug 1059144: Refactored nodejs control script

* Moved functions into util file to make debugging easier
* Kill 'node' processes when 'use_npm' instead of killing 'npm'