This can apparently be fixed by not assigning the window to the sandbox but instead add the function
objects directly to the sandbox. Seems as assigning a window to a sandbox somehow cripples the window object.
I attach a patch that solves the problem.
This assigns all nkfoo functions to the sandbox that can then be used by the script. I can't find
anything on the conkeror.org page about procedures external patches so I hope that this is alright.