added test; big fixes