improvements to tests.py, cleaned up some API real() bugs