Add test for whyrun-safe in ruby blocks

Also refactor the code to be slightly cleaner and fix 'updated' bug.