degree function with test added