Remove all implicit imports in doctests.
Implicit is better than explicit. These implicit imports often leads to questions being answered on mailinglists about where these imports come from. It is easier to have them explitly defined instead. Also, move some commented helper functions out to be visible so that again users aren't confused about where the magic functions are coming from.