fixing resource leak in test