Code is not a spec. It's an instruction set. It can be a spec if you try hard but that's not an inherent property of code. For example you can write code to be a compiler..that makes it a spec. But hello world is not a spec.
As for whether or not LLMs can write unit tests. The answer is yes.
Hello world is a spec. The spec says to produce the text hello world on standard output.