Changed all console.error calls to emit('error')
Small lint fix in test.js