Fixed misc. bugs and updated test.py