Fixed calclulateWays for orders and added test