refactor and test extractAppIdAndSpaceIdFromURL function