added stats email code
merged
added tests and fixed unauthorized channel metrics
fixed declaration