Added some tests (as they pass now).

Added tests from #494. They pass now, so after merge this PR we could close source issue.