change Exception , add individual tests and add checking for null array.