added more unit tests and fixed some issues