Fix exit procedure calls in nested states

Fix exit procedure calls in nested states. Also, changes the test makefiles for using gcc instead of clang.