[backend] spawn_instance refactoring & unittest