Alter Context _insert_task setting logic to validate function.

Require a callable function to be provided for insert_tasks, or nothing
at all.  Specifying any non-callable value is considered an error.
Adding to_dict method to Context to facilitate persistence.

Context objects need to be encoded so that they can be passed between
requests and / or persisted.  A first step of this process is encoding
Contexts to a JSON serializable format.
Add from_dict method for Context to produce a Context from a dict.

from_dict is the inverse function of to_dict on Context.  This is
required to facilitate the reconstitution of a Context that has been
encoded and persisted to disk.