Merge pull request #150 from MaggieQi/master

rewrite some examples and their tests to make code more clear and optimizable