fixed inversion
added test for inversion