-- adding test code from lgrapein pull request
-- sync to commit
-- merging in changes from lgrapenthin
-- fixing some merge errors