Beating rural decline: these three towns think they've cracked the code