Updated stubbing and use of let in order to comply with deprecation warnings