THz spectroscopy of excitons in bulk GaAs and in AlGaAs/GaAs quantum wells