Added main and test R scripts