[TASK] Throw appropriate exception and add test