Fixed variance calculation and added stdev tests