Add tests, remove some debug logging