Many more unit tests, first half of helper functions