Added a few unit tests and bugfixed