Fix test leaks - fixes #775