Updated and added unit tests.
Bugfixes and more unit tests.