Turn analyseTestSet into function