made getRequestfromDataServer function for reducing duplication and made test readable