Fixed #27. Also made tests for it.