add componentWillLeave and fix test