How do I use RMAN to create a test database from a full recovery backup dataset?
First place to check is Oracle official documentation.
For example http://docs.oracle.com/cd/E36909_01/backup.1111/e10642/rcmdupdb.htm#autoId0
Depending of your database version(10g, 11g, 12c...).
Just search documentation for duplicate database.
I am not going to explain all questions from your script because it could only confuse you a little more.

Depending of prod db size you could use datapump export and import for example, or transportable tablespaces or like you tried RMAN.
Your rman commands should be something like

-- scripts for restore using RMAN, 
-- This script is usable when the oracle versions are the same, 
-- or a direct upgrade is supported
--
-- prep database for rman import
rman target /
shutdown immediate
startup nomount
exit


-- duplicate the database
rman auxiliary /
duplicate database to newdb
  backup location 'E:\Backup\oracle\flash_recovery_area\olddb\BACKUPSET\2016_07_29' nofilenamecheck 
  DB_FILE_NAME_CONVERT ('E:\app\oracle\oradata\olddb','E:\Oracle\oradata\newdb')
  LOGFILE
    'E:\Oracle\oradata\newdb\redo01.log' SIZE 2G,
    'E:\Oracle\oradata\newdb\redo02.log' SIZE 2G,
    'E:\Oracle\oradata\newdb\redo03.log' SIZE 2G;

duplicate database to testdb spfile backup location 'backup_path' nofilenamecheck;


When the databases are of different versions, use expdp/impdp:

-- Alternate procedure using using expdp / impdp
--
-- Export on source database
sqlplus: create or replace directory data_pump_directory as 'f:\dp';

cmd: expdp user/password@olddb schemas=SchemaToMigrate directory=data_pump_directory dumpfile=dbname.dmp logfile=expdp_dbname.log

-- generate script for generating user from old database
-- see http://www.oracle-scripts.net/generate-user-ddl/
--
-- copy output files from source system to destination system
--
-- Prep destination database for the import
-- use script generated above to create user/schema on destination database
sqlplus: create or replace directory data_pump_directory as 'f:\dp';

-- From bitter experience, this will not necessarily work with the user/password@newdb 
-- on the command line.  
-- If impdp chokes with ORA-39087:
-- 1. Confirm database is open (alter databaase open)
-- 2. Confirm the directory reference is created in the database
-- 3. Confirm the system and schema users are granted read and write on the directory reference
-- 4. Confirm the oracle service (OS) user has authority on the OS directory
-- 5. then try not supplying credentials until impdp asks for them (yeah,  a possible bug somewhere)
cmd: impdp user/password@newdb schemas=SchemaToMigrate directory=data_pump_directory dumpfile=dbname.dmp logfile=impdp_dbname.log table_exists_action=replace  remap_tablespace=oldts1:newts1,oldts2:newts2


This script can be written in many ways, depending if you want to recover to specific date and time, specific SCN, is test db the same structure(the same path for data and other files) or not, the same operating system or not, do you need to change some initialization parameters or not etc.