fixed call to sys.stderr
raise commanderror when needed
added tests