Changed toThrow expectations to anonymous functions