Added new autotests and refactored the autotest script.