Fixed several bugs to the auto-create feature after test, and added some unit tests to it