Ensure that cosmology tests don't have any side-effects

@mdboom - this should fix the issues you were seeing with the cosmology doctests, so once it's merged, you can rebase your branch?