fixing code that interacts with server side for refactor and adding new tests