core: fix nested try-catch blocks processing

Add code for processing nested try-catch blocks. Add a related test file.