I think that the change in layouts "loses" the focus on the current row in your portal on Portal Test. Also, go to portal row cannot specify a particular portal so care must be taken if your layout should ever have more than one portal or it may go to the portal row. of the wrong portal Give your portal's an object name and use go to object just before go to portal row to be sure that you are interacting with the correct portal.
Given those issues, you may want to consider one of two approaches that avoid intracting with specific portal rows:
1) Use Go to Related records to pull up a found set of records from the portal test layout's portal on a layout based on the portal's table and loop through those records. Changing layouts will not change which record is current.
2) Use set Variable [$TheList ; value List (Proposed::Class Name ) ]
to capture the full list of values from the portal in a list. Then use a counting variable such as $K and the function GetValue ( $TheList ; $K ) to refer to a specific value in the list. This last option can result in faster execution--a key advantage when working with large sets of related records and or slower connections such as that from a device using FMGO.