Unit tests for main logic
Moved the wild card logic into a function as it was duplicated three
times