Added contracts and fixed negative test