fixed another bug, introduced by optimization
added more test examples