Place update_state methods out of db session

Place update_state methods out of db session;
Match package installer name by regex.
patch2: fix style

Change-Id: I26d3f21e2d3c022ebe2b4635583c33074434ae46