Reorganized to allow for testing at both client and server sides