Add try-with-resources to test class.