Replace assertions with descriptive exceptions

Use a decorator "replace_error" for methods, when it make sense to
raise only one kind of error in their case.