Move declarations of variables to the scope where they are used
Add R script that generates test data