Fix some bugs. #32. Not finished yet.

And added some test files related in the "test" folder.