If you haven’t done so already, you have to create a unique password in your google security account settings for the imap access from home assistant, because access is being achieved through a ‘less’ secure method. You use your google account and this unique password to access your emails from home assistant.
Secondly, the following search criteria for ‘test’ in the SUBJECT worked for me (there are no quotation marks or chevrons required) :
As I’d given my IMAP entry a friendly name of email (name: email), this returned a state of 1 from sensor.email (the number of emails that matched the search criteria).