refactor matchable, matcher and add units and functional tests