Fixed bug 590, added regression test