Update to use proper try ... finally blocks in test