Add cnf conversion function and test code