Formatting and naming refactoring

Changed names to be more consistent, fixed implicit variable scope
on testsuite_external, reordered functions by their groups.
Code style improvements, comments and cleanup

The setup and teardown functions were also removed until
they're needed.
Moving code that detects current shell to its own function

Code that tries to find the current shell was moved to a
separate function, so it runs only when needed and only
one time.

Tests for the testsuite_exec_ family of functions were added
as well.