Added more tests and changed chi-squared distance to another simpler and less buggy method