added mocha tests - all tests passed. fixed bugs.  added grunt task to run tests.