Added stack testing, bug in stack code