put server test code into function