Added a finally to ensure resources are cleaned up even if the test
fails