Replace bracket (bash) operators

Replace bracket operator (bash) in set_direction function. Use test -f instead
in order to improve compatibility with different bash versions.