added the inject method
added the tests for inject method
changed inject method by using while loop instead of each method