bugfix: add upstream after delete local upstream will cause a coredump and added some test case