Mock atexit.register during doctests

Prevent calling the standard library's atexit.register() function during
doctest runs of the documentation. This avoids exceptions during the
interpreter shutdown.
Raise exception if decorating non-callable

If the object being decorated by the begin.start function is not
callable, raise a ValueError exception.