Handle case of positive lng with a negative magnet close to date line

Plus add some first unittests.