Merge pull request #22 from fengjingchao/inst

Add more test and refactor code
fix test in set up preparing instance