refactor test  status code to function