Is this what you want?
$ sed 's/\(^\| \)test3\( \|$\)/\1/g' file
test3.legacy test4.legacy test3.kami
This say
substitute
(^ start of line OR space)
test3
(space OR end of line)
with match 1 (AKA space or start of line)
* * *
**_Update:_**
And as so elegantly put by the good @Stephane Chazelas this would not take care of certain cases. Also emphasize on the portability part. See answer below.
A GNU variant could, _(hopefully)_ , be:
sed 's/\(^\| \)\(test3\( \|$\)\)*/\1/g'
# Or perhaps:
sed 's/\(^\| \)\(test3\( \|$\)\)\+/\1/g'
taking care of repetitive matches. Optionally one would take care of multiple spaces etc as well. Depending on input.
EOUPD
* * *
As an alternative perhaps ( _only meant as a starting point_ ):
sed 's/\Wtest3\W/ /g'
Not this I assume:
$ sed 's/test3\.\?[^ ]* *//g' file
test4.legacy