tweaked to support abstract inheritance, with test