Fix bugs about checking pre-created context handle