Tidied up setup and put into client/server methods for reuse.

Signed-off-by: ZackLyons <z.lyons@bath.ac.uk>