Refactor matcher to be a function (simpler.) Wrote tests for new API.