refactoring and formating
added command-test functions