Why AppleScript in El Capitan runs differently?
The on idle and quit handler are for Applets, not Scripts. Applets and scripts are different, however they are both written in Applescript.

An applet, is script application, which support idle and quit handlers, while script is like any other script in any language; it runs and till the end, doesn't know when it's about to exit, or when it's idle. Applet it like any other application, if you right click and "Open Package Content" of an applet you'll see the resemblance. Applet can have resources, can be CodeSigned, can have multiple script and shared without any problem.

That's your problem, choose to save the script as an application when asked, also select "Stay open after run handler", then your idle handler will run.

Few more things, it's always a good idea to return out of every handler, which you aren't in run and testing, this can cause the idle handler to not run as it'll be waiting for run to finish. You should also insert continue quit in your quit handler, otherwise it'll never quit; you'll have to force quit it.

For more info AppleScript Language Guide