fix bugs and finish tests
Merge pull request #2 from mpkato/merged

fix bugs and finish tests