Added mocha tests. Changed exceptions to emit 'error' events instead of just throwing.
Added travis ci support.