ENH: added before_environment instruction
FIX: catch all errors