Added tests to fix bug #142