Oh yes, you're right -- it's because of the behaviour of "load".
However, this should solve the problem:
(define-macro (define-test-function)
`(define (test-function)
,(with-input-from-file "external.scm" read)
x))
(note however that it would load only the first sexp from
"external.scm", but I think that it should be a sufficient hint)