Fix minor issues in `gamma` function. Added tests