app return code added + fixed loop control for tests