Fixed a bug where stack array wasn't using right array size definition. Added an unit test to catch this kind of errors.