Fix NPE closing server in tests

Change-Id: Ib56c37ae02ea7c3ab69991d3ee479bd6e57a17d4