Minor cleanup, add first couple of unit tests