test_tls: Simplify cert chain building
test_tls: Simplify cert chain building

Moving the logic from module-scope to function-scope makes the
tests slower but the code is much simpler now.

Synss/python-mbedtls,Synss/python-mbedtls