Fixing bug in average calculation (Submitted by Lars)

1. A minor change which makes the AVG_NUM configurable by compiler define.
2. The more important change: A fix for a bug which caused the check_ntp_time
   and check_ntp_time check to always take the first response from ntp and not
   the avarage since "j" is not increased anywhere. "i" should be used there
   instead.

(Closes: #956)
(Closes: #1089)
(Closes: #1166)