Make Task's map and flatMap exception-safe

If a function passed into map or flatMap throws an exception,
this is now converted into a returned exception.

Tests check that this works for tasks created by Task.apply,
delay, and now. Note that the failing case for these tests is
that they never terminate. Before this change, throwing an
exception causes thread termination, and another thread waits
on it forever.

This resolves #573