Moves some of StateAttribute functions to the base class

It simplify code for StateAttribute
Simplify a bit of code for custom StateAttribute