fixed #4, fiddly but adequate for basic checking. Basic test added too
more test/doc improvement