added gamma calculation and gamma tests