bug fix and test fix; (thanks Martin Garton)