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