Added check for the before and after method invocations.