Add mocha unit-tests for lb-ng script

Fix the bugs found along the way.