rewrite test-examples, and fixed some bugs