alarming mechanism improved, code refactored, tests refactored