Add ImportInstance and some bug fix.
Add a test case for ImportInstance.