Add new unit tests, fixes