I noticed that the gcd function doesn't give correct results when one of the values is 0.
For example when we let a=0; b=6; and g=gcd(a,b);
then {g} appeared in the problem as 1. So apparently gcd(0,6) = 1 (it should be 6 of course).
And g=gcd(0,0) returned {g} as 1 as well.