The match function expects a regular expression as its second argument. Every regex has an implicit .* at each end unless an anchor is used. That means the match in your sample code will match any expectedm that contains the digit '1'. To look for exactly "1", use expectedM=^1$.
--- If this reply helps you, an upvote would be appreciated.