[baclend] spawn_instance refactoring & unittest