fix error throwing and added test