Function setupClientWithCustomMain