Clean up anaconda_mode.py and add missing tests