Use % instead of [[ for finding the opening brace

[[ will only match opening braces that are located in the first column which makes af and if work incorrectly with other brace positioning styles. This commit switches to % instead which will always find the matching brace.

This seems to pass your current tests (it took some time to install the whole test toolchain successfully :D). I didn't want to write any new tests since I'm still not very familiar with the test toolchain.