Add automation test script

Add automation test script and fix bugs