Fixed bug #194, added regression tests