cf-dc-api.pl: restructure selftests and log better; add more selftests