cleaned up scanner and added tests with mocha