Moved test and changed to use enumeration algorithm