I did not check a code by eyes, but it looks workable.
Sub PrepareAndWriteStrings prepares "strings" and writes them to disk.
Of course, similar subroutine will not a part of real program. We need to write to disk once only.
Then Test activity reads previously prepared strings into memory and converts them to CSBuilder. To do this it uses a mapObjects, which is necessary to create in run-time.
I was not able to move restore part into class due to Clickable / EnableClickEvents.
Guess, the same problems like in your code. So I used a module.