Fixed inheritance and added unit tests