Added test routine and made gamma more clean