richer library interface and tests