Changed how alerting is done, added tests