added stack size validation and tests