These share quite a bit of common-like code, so refactor
both of them to share the same function and differentiate
certain provided arguments as needed.
Also tweaks the storage class 'get_atoms_states' (which
is badly named also) to not do two queries into the flow
detail when one will suffice and to not request the same
atom name twice when once will suffice.
Change-Id: Ifdf2f3efb78d189ed5a8104614b1bf6a84c9339a