refactor alarm and alarm_test