test.py and fixed a couple bugs