#31, more unit tests and fixes