adds .on("error") handler and test