update gc.py and add tests