Fixed a small bug from experimental code.

Added test case to catch similar bugs.