I'll try to summarize this article written by a respected and knowledgeable member of the community, but I'd read this if you want a more in-depth coverage on this topic:
http://blog.mastykarz.nl/dynamically-loading-javascript-sandbox/
I don't think you can use the Register Client scripts (in a Sandbox scenario) on the server side because of the limitations of the Sandbox.
So, yes, you must register them another way. How you register depends...on what you are trying to do in your test() javascript method. If you are relying on functionality exposed by other javascript files, then yes, it'd be appropriate to use the SP.SOD (script on demand) framework to setup dependencies on your file with other files. For example, if your test() method is trying to leverage the Javascript Client Object Model, for example to read contents of a list, then you would use the ExecuteOrDelayUntilScriptLoaded() method like so:
ExecuteOrDelayUntilScriptLoaded(test(), "sp.js");
BTW...ExecuteOrDelayUntilScriptLoaded() is just a part of the SOD framework and is loaded by init.js. If your test() method is relying on functionality exposed by your own scripts (i.e. not SharePoint provided scripts, for example jQuery), then you can also use the SOD framework, but you must ensure that your custom script file is setup to participate in it. You do this by putting a call to NotifyScriptLoadedAndExecuteWaitingJobs() at the end of your file, which lets the SOD framework know that your file has finished loading, and any dependent scripts can now run.
Here is another good resource covering SOD:
http://spblog.net/post/2012/01/20/SharePoint-2010-Script-On-Demand%E2%80%93give-my-script-right-now!.aspx