Test and implement replacement() context manager.