Bugfixes
Added unit tests