fix test before and after logic