Some refactoring
Merge pull request #19 from mikedao/tests

Some refactoring