Sensor, Switch availability template

I would like to modify my “availability” templates for my sensors and switches.
Currently, I use a template like this to check for availability:

availability: "{{not 'unavailable' in [states('sensor.f1_energy'), states('sensor.f2_energy'), states('sensor.f3_energy')] and not 'unknown' in [states('sensor.f1_energy'), states('sensor.f2_energy'), states('sensor.f3_energy')] and not 'none' in [states('sensor.f1_energy'), states('sensor.f2_energy'), states('sensor.f3_energy')]}}"

It looks ugly and hard to read.
I tried a different method like below:

availability: "{{[states.sensor.f1_energy, states.sensor.f2_energy , states.sensor.f3_energy] | rejectattr('state', 'in', ['unavailable', 'unknown', 'none']) | list | count > 0}}"

However, testing this with the template editor with below expression does not give me the results I want.

{% set y = 'unavailable' %}
{{ [states.y] | rejectattr('state', 'in', ['unavailable', 'unknown', 'none']) | list | count > 0 }}

The above expression gives a “True” result whereas I expect a “False” evaluation.

Though, testing with actual sensors which is ‘unavailable’ instead of setting a variable gives me the correct results.

Why is that? Can anyone enlighten me? Is there a better way to create such an availability template?