more robust am_i_online, use template code instead of script, include tests