Tests and partial implementation of greatest common type, and moving to RAII for type structs like I should have done originally