added some unit tests and store and for loop detection