Fixed calledWith error throwing and added tests