WIP on tests. Some minor cleanup.