KMeans unit test memory leak fix

- fixes #1837