More logging, and tests