more unit tests and bug squashing