added test and changed stack iteration to top-bottom instead of java default of bottom-top .