add new error codes
code cleanup
change test cases to reflect new error codes
fix wrong rc check
fix indentation
code cleanup