unit tests copied from scgl