Degree Function Added with Tests