Added tests. Error events is handled using on('error')