Code cleanup.
New test.
Fixed #219.