Refactored before and after routes. Added wrap tests