Refactor stub method using helper methods to set/restore var