Added on('error', ...) callback. Found and fixed an error in the test.