#53 adding junit test to reproduce error and adding patch as proposed by
Andy
some minor cleanup