refactoring specs and add error 500 handle