stackcommands and refactoring test case with context