add docopt-based test.r function