subclass-friendly code improved, test added