Added tests, fixed bugs in polygon.py