Scopped and logged monkey patching for unit tests