I had refractor my code and test it

@eriwen I had complete refractor for last pull request's code by extractored methods to express clearly,add basic validation,etc. At last, I test it with followed cases: 1 -w on/off 2 -k on/off 3 1basic+2append 4 3append 1 only basic info 2 only append info and What's more I use jenkins to publish the result, it is all OK. So can you help to review my code and request and take a merge now, Thanks a lot.
PS: I will close the last pull request.