Issue #183 test suite

Implement test suite to check issue #183 functionality.
There was quite a big work and I modified exising testing code and making it more common. But now it seems to be working fine.