integrate the unit tests with the package
fix some bugs introduced by the restructuring

* thank you, unittests