finish test and fix some code bugs
added a code example