Fixed a small performance issue.
Also fixed interactive mode in basic_testcase.py