Scotland survive scare to edge Italy in Six Nations